i guess i found the root cause of the inconsistent behavior. there is another hook called uselayouteffect
uselayouteffect the signature is identical to useeffect, but it fires synchronously after all dom mutations. use this to read layout from the dom and synchronously re-render. updates scheduled inside uselayouteffect will be flushed synchronously, before the browser has a chance to paint.
the uselayouteffect will block the painting while the useeffect will not. that confirm and explains my guess that the didfocus event had fired, but it didn't trigger the listener since it miss the timing
so in my case, i have to use uselayouteffect instead of useeffect
- React navigation didfocus event listener works differently between class component and functional component
- React custom hook with event listener not works while updating the state
- React Navigation "focus" event listener does not use updated value
- this inside react class component works differently
- Add Event Listener to items by Class in React
- Event Listener on Navigation with react router v6
- Wrong React hooks behaviour with event listener
- Remove Event Listener On Unmount React
- React Navigation V2: Difference between navigation.push and navigation.navigate
- React setState hook from scroll event listener
- Removing event listener in React (lodash.throttle)
- React hooks value is not accessible in event listener function
- Using transitionend event listener with react to create a transition
- Unsubscribe from event listener react hooks
- How does React router works and what is the difference between <link> and<Route>
- React navigation event listeners being called multiple times
- What is the difference between arrow functions and regular functions inside React functional components (no longer using class components)?
- adding event listener for keydown to react element
- Remove event listener manually react hooks
- React JS: Differentiate between Click and Click + Shift event
- Performance comparison between react hooks and react class
- onDeviceReady event listener in react component
- React Native - Global Event Listener
- What’s the difference between React event and DOM event?
- React event.target is not the element I set event Listener on
- React Native Stack Navigation With Class Component
- Event listener functions changing when using React hooks
- how to use react devtools to get function tied to an onClick event listener
- How can I use react navigation props in class component?
- React Warning non-passive event listener to a scroll-blocking 'touchstart'
More Query from same tag
- How do I put notification alert on the border of the table?
- React/Recoil: once state is set in the main app, cannot be set again inside a component?
- How to show a loading indicator during sending API request
- TypeError with "Cannot read property 'length' of undefined"
- React/Antd: Dynamic form fields based on JSON response
- images in Django project only visible when img src='/media/...' not with img src='127.0.0.1/media...'
- Why does the React dialog require componentWillReceiveProps and popup again when Stepper changes?
- Does passing objects as props interfere with componentWillReceiveProps?
- I need to capitalize the next string css
- How do async redux functions work?
- React Next.js: getServerProps is not returning array from prisma
- Transferring data between React elements
- React fetching data twice
- is there a way to have mui v5 render the classnames without the css-yyy prefix?
- Jest Enzyme Test for A Component
- How do I switch from class to function in that case
- How to find records from database according to the typed string in the ReactJS search bar
- Pass child data to parent?
- Showing error when I use map function in ReactJs
- How to define React Navigation navigationOptions parameter in Typescript
- Why doesnt the align-self: flex-end css property doesnt work on flex div?
- Fetch all images at once and show 360 product view in Reactjs
- react-bootstrap-table auto column width
- POST 403 forbidden CORS response when uploading an image to AWS S3 bucket ReactJS
- Problems using html-to-image in a React application
- React Uncaught TypeError: cannot read property x of undefined
- CSS file is applying on another react component even without importing
- Getting white screen on running npm start in my react js project
- React-Query: How to useQuery when button is clicked