score:0
If setVisibleExtras
changing extras
it will always trigger whole useEffect again... if its your case, use callback function in setVisibleExtras
instead:
useEffect(() => {
if (extras.length && pkg ? .id) {
setVisibleExtras((extras) =>
extras.filter(({
availableOnTariff
}) =>
availableOnTariff.some(({
id
}) => id === pkg.id)
)
);
console.log('visible extras', visibleExtras);
}
}, [pkg]);
Source: stackoverflow.com
Related Query
- useEffect doesn't work correctly even when setting the dependency
- useEffect hook is turning into infinite loop even when the dependency is not changing all the time
- Why does useEffect fires on page reload even when the dependency is not changing?
- InfiniteLoop in useEffect when one of the dependency is a function from useContext
- Why the input doesnt work when generated by React
- When I try to setState in useEffect it doesnt work
- React warning React Hook useEffect has a missing dependency when the deps are []
- useEffect running on every render even when dependency is unchanged
- setting the state inside the useEffect with that state as a dependency
- React Router doesnt work when I try to render the components
- Why does useEffect run the first time even when it is listening to a prop?
- When using the useEffect hook, the method of using a dependency array is confusing
- socket connect event inside useEffect does not work when component is created but works after refreshing the page in React
- How to fix missing dependency warning when using useEffect React Hook
- React useEffect Hook when only one of the effect's deps changes, but not the others
- React useEffect - passing a function in the dependency array
- React Hooks - useEffect fires even though the state did not change
- When is the cleanup function triggered when using useEffect hook with dependencies?
- React Hook useEffect has missing dependencies. Either include them or remove the dependency array
- React.PureComponent doesn't work when the Component has children?
- nextProps always identical to this.props in componentWillReceiveProps, even when the props have changed
- Reactjs redux: Fetch PUT method sending only an OPTIONS method, even when the status is 200
- useEffect missing dependency when using redux useDispatch
- How to fix "React Hook useEffect has a missing dependency. Either include it or remove the dependency array" problem?
- Why is a state variable's setter needed as a dependency with useEffect when passed in through props?
- useEffect not working when dependency value changed
- ReactJS: useEffect is not run when the url changes
- react useEffect trigger although dependency value remain the same?
- React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array react-hooks/exhaustive-deps
- Setting the default value inside the input field in the antd library after calling the function in useEffect
More Query from same tag
- How do I conditionally render an object to display one section of code if the object is not empty and one section of code if the object has key: value
- Page not scrolling down even though when reached bottom in React?
- Why is this variable both empty and not empty according to the class state's logic?
- Why am I getting this error in my CollectionCard.js (REACT)
- Make table cell textOverflow dynamic as per width
- Rewriting a react-addons feature on React 15.1.0
- How to use react to listen a loop events with contract?
- Display label if list is empty
- Next.js dynamic route - 404 on page reload after added SLUG
- React Redux ->How can I map over my state?
- Drop down menu when click on the icon- ReactJS
- React: How to solve: Property 'children' does not exist on type 'IntrinsicAttributes & Props'
- Why this function component doesn't re-render after setState?
- How to add font-awesome icons from sources with SASS?
- How to make a use of arrow function in es6 instead of bind method
- How to iterate over object with a component in redux
- How setup react-helmet with Server Side Rendering?
- How to sort the antd-table while keep one special line forever on the top of the table?
- How to refer to a DOM element inside a child component? [ReactJS]
- React Router v6 not showing nested route - what am I missing?
- Navigate to a section of another page in MUI 5
- React Hook Form using Controller, yup and Material UI - validation issue
- Delete element from array in redux state using a reducer in createSlice
- ReactJS DropZone browser attempts to open file on drop
- React + Firebase Cloud Functions in Typescript fails to deploy
- I can't update create-react-app, any suggestion?
- DJango React Not found
- Admin on rest Create form - merge firstName and lastName into a third field
- How to limit the amount of pages in my Carousel?
- Many components with the same reducer but different initial state