easy5 pts · first answer countsreact-nativereact-state
Calling setCount twice
In this React Native component, count starts at 0. What is count after the user presses the button once?
const [count, setCount] = useState(0)
const onPress = () => {
setCount(count + 1)
setCount(count + 1)
}Discussion 0
Join free to post in the discussion.
Related questions
- Why list items need keysMobile App Developer
- React Native New ArchitectureMobile App Developer
- Listener without effect cleanupMobile App Developer
- Timer counter stuck at oneMobile App Developer
- Animation stutters while JS is busyMobile App Developer
- Memoized rows still re-renderMobile App Developer
- Changing a prop inside a childFrontend Developer
- Syncing derived values with an effectFrontend Developer