score:0
Accepted answer
write another useeffect and put data dependency in an array and clean up second then in your useeffect becaucse that is unnesseary
useeffect(() => {
const olddtate=[...data]
olddtate.foreach(element => {
let options = [];
if (options.indexof(element.category) < 0) options += { value:
element.category, label: element.category };
setc_options(options)
}, [data])
Source: stackoverflow.com
Related Query
- useEffect problem don't work when fetching data
- I'm fetching a problem when I'm trying to fetch data from an API by using useEffect in react
- Infinite rendering of component when fetching data in useEffect wrapped in HOC
- Why does optional chaining allows rendering when fetching data through useEffect in an app that uses context?
- (Reactjs) "delay" when fetching data using useEffect and useState
- Handling errors in useEffect when fetching data from an API
- Data fetching with useDispatch inside useEffect (code work but with error)
- React router problem fetching data when needed
- React useEffect looping many times when fetching data and setState using fetch API
- Async useEffect does not work for fetching data
- Problem with useState, UseEffect when saving data when getting data
- React hooks doing an infinite fetching when getting data from child but has no problem if the parent is a class component
- Problem with custom ContextProvider state when using custom hook for fetching data in multiple tables in React
- React Problem : I tried file data set in state when upload file, but it isn't work
- REACT - Express : fetching data doesn't work on reload when user connected
- I have a problem with fetching data with useEffect
- ReactJS not fetching data from server when using 'url' attribute
- using useEffect in combination with Axios fetching API data returns null - how to deal with this?
- Render is called twice when fetching data from a REST API
- Avoid old data when using useEffect to fetch data
- Unexpected behavior when fetching data with hooks
- How to hide and show progress bar when fetching data from network?
- State management with useContext and useReducer and fetching data with useEffect
- show loading when fetching data react
- ref.current in useEffect deps doesn't work when expected (compared to useCallback ref)
- Loading screen when fetching data via Redux
- Why useState doesn't work after fetching data
- Keep getting TypeError: Cannot read property 'map' of undefined when I click on checkbox, dont know where the problem is
- How to prevent React Hook's useEffect from fetching data multiple times
- react useEffect is running and fetching data none stop
More Query from same tag
- Can we use both MUI makeStyles and Theming in _app.js
- How can we write a click handler for a Stateless Function Component in React JS
- Warning: flattenChildren(...): Encountered two children with the same key / Child keys must be unique
- How do I return a JSON array in React from a local file and have it map through all of my items?
- React router 6 side-effect clean-up on unmount
- Why my I am not able to print sum of numbers from react-redux state?
- align items next to each using bootstrap
- Property 'splice' does not exist on type 'T'
- How to solve 'this.props.items is undefined' in React.js on Firefox?
- Migration from redux to redux-toolkit made react app significantly slow
- Can't edit input when assigning a value with useReducer hook
- Hide and Show Looped Components in React
- how to add border to otp input digits
- Jest/Enzyme - How to use nock library with a connected redux store component?
- Change default color of Link from blue to white
- Fetching data from API and using it in JSX is giving string output to the html tag
- How to prevent from upvoting twice in Firebase
- How to output components by some of their fields?
- React: condition based on url (image)
- Why isn't jest's clearAllMocks working and how do I clear mocks for jest spies?
- can we set a specific route to show insted of an dynamic route in nextjs?
- How to render a maximum of ten items in the react.js object
- accessing url parameter in react-router
- Rendering specific component using switch case --- React
- React and wrappers for plotly.js charting
- React fullCalendar - Interaction not working
- Checkbox clicked style dissapears when i press dropdown option through useState in React/Next JS
- How to read props expression found in React app
- How to use ternary operators and display the data in react js
- Material UI Autocomplete Chip multiline