score:1
Accepted answer
i think the issue is where you spread the old state into setstate
the state has gone stale. react does some performance enhancements around setstate that will make code like this not work as expected.
one thing to try is using the setstate callback.
setstate((state) => ({
...state,
projectlist: sorted
}));
Source: stackoverflow.com
Related Query
- How do I correctly add data from multiple endpoints called inside useEffect to the state object using React Hooks and Context API?
- How to prevent React Hook's useEffect from fetching data multiple times
- How to fetch and display data from multiple endpoints in React?
- How to fetch API data from Axios inside the getServerSideProps function in NextJS?
- How to dispatch an redux action to load data inside useEffect on page load
- ReactJS - how to fetch multiple data with useEffect
- React: How to add onChange functionality inside of Function component using React Hooks? Need onClick event from a checkbox to influence input state
- How to deal with UseEffect running multiple times due to retrieval from Firestore DB?
- How to use the global data from React inside Apollo client's initialization?
- How to fetch data from multiple urls at once?
- How to correctly add and remove specific items from an array within state?
- React.js Chrome Extension - How to store data from Background.js in a variable inside React?
- I don't know how to get data from fetch correctly
- How can I make a request to an API based on the response from another request? React Hook "useSwr" cannot be called inside a callback
- React Router "Link to" does not load new data when called from inside the same component
- How do I pass the text data from firestore inside the expandable row and get the document ID to be passed inside the setState?
- how to set an useEffect to fetch data from API at first render with eslint-react-hooks?
- React: How to use multiple Contexts of the same type while allowing children to read data from all of them
- How to access data from query inside component?
- How to extract data from material UI elements and add an onSubmit function to send data to backend
- How to fetch data from different APIs inside one redux-saga?
- how do you prevent functions inside useEffect from being triggered more than once?
- How to use Abort Controller to abort APIs initiated from inside useEffect but triggered by user action?
- How to correctly add an if statement inside return statement in react?
- How do I return data from multiple APIs to display on one page in React?
- React - How to add local data to data from a REST api?
- reactJS How can I add a search filter for data from the db
- How to use data from fetch correctly in React document title?
- How to correctly add event listener to React useEffect hook?
- React - how to stop useEffect from being called continuously without altering dropdown
More Query from same tag
- React+based on prop value i need to initiate a function which is already present in child component
- How do I prevent infinite loop when isAuthenticated is undefined in React Router?
- react hooks must be called in a react function - how do I change syntax to correct?
- How to show the comments from an API which is in tree form in react?
- custom filter for includes - strapi
- input form sending blank value in reactjs
- d3 forceX not positioning circles near their x axis value
- Typescript build issue with lerna
- gh-pages doesn't show my site (don't find index.js)
- Unmounted component warning when trying to filter through pulled database information
- localstorage is not defined in Next js to use in useReducer
- Getting data from Firebase via Reference from props
- Using higher order component in Typescript
- React: Is useEffect not guaranteed to run before the component renders?
- Display total of grid column values in react-admin
- Cannot read property 'length' of undefined when trying to get # of objects
- React rendering with different content based on api response
- reactjs charts implementation
- React-js: Objects are not valid as a React child
- How to customize Syncfusion React Scheduler component?
- Transfer raw json data to html table in reactjs
- How to Fetch JSON data from GET Request FLASK-Python
- How Redirect when a Promise is Resolved?
- React-three-fiber useEffect , useState, THREE.Clock
- Draft JS update EditorState from external script while maintaining undo/redo stack
- ReactComponent vs ReactComponentElement in scalajs-react
- Convert string to date in map loop - ReactJS
- How to access nested props object in React TS?
- setupProxy.js path are not recognizing in reactjs application using http proxy middleware
- The correct way to bundle CSS modules