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
- ReactJS - External JS Function "is not a function"
- Tags not rendering in React
- Webp images doesn't render correct
- Redux dispatches are not firing for fetching API
- Downloading a docx file via react.js
- What is the correct way to push jsx with embedded js variables on to an array
- how to make drop-down 100% width that contains another drop-down in react js?
- Submitting a Redux Form
- Material UI | React | OnClick Event always sends the last index
- Login form cannot get data from back-end in React
- Is it possible to make fields required on material-table
- ReactJS + Flux: How to pass data attribute from HTML?
- Is there a way to dynamically set className with css module? To be used with CSSTransition library
- Boost strap Grid system
- React-Router-Dom: Make Home The Landing Page
- .map() issue in React
- How to add multiple styles based on property with styled-components?
- onClick not working reactjs in button despite binding
- Invoke form submit with a onChange event
- React.js get events on SVG's path
- Sticky Header and Footer using React
- How can I fix "Cannot read property 'document' of undefined" when directly accessing the url? Next.js and apexcharts lib
- React page not updating on socket message push despite the data being sent
- What exactly is anti-pattern in reactjs?
- propTypes should be a func console warning when passing in array of icons
- How to use dynamic meta tags in react single page application?
- React: prop is not passed to child component on parent re-render
- How can I show sorting icons all the time and with blue color for current sorting column in react material-table
- Error "rollbackFailedOptional" on create-react-app
- Why cant I highlight the text on my screen in my react component?