score:0
i am still not sure why i can't update an array state in a loop but i have found a turn around for this. rather than putting
setmessagestate() in usestate, i have put the for loop in the function settablecontent() itself.
const settablecontent = (row: number, err: any) => {
const values = []
for(let i=0; i < 6; i++) {
values.push(getstatus(i, err));
}
setmessagetype(values);
}
and now its working
Source: stackoverflow.com
Related Query
- React state taking previous initialized values when updating
- React useState hook - when to use previous state when updating state?
- How to define TypeScript types when used with React useState and the previous state inside a state updating function?
- How to keep previous values when updating array in React with useState
- State not updating when using React state hook within setInterval
- React component not updating when store state has changed
- Props not updating when redux state change in React Hooks
- Updating the react component state when a global variable changes
- Why React does't compare Previous State and New State before re rendering? Why it always render when setState is called?
- Too much recursion when updating state in react
- React is not updating when Redux state is changed below the first level
- Prevent infinite loop when updating state via React useEffect Hook
- setInterval updating state in React but not recognizing when time is 0
- How to maintain previous changed state in REACT JS as when new item is updated, previous is set to default?
- React keypress event taking only initial state values and not updated values
- React setState() not updating state when button clicked
- React useState when updating state twice, first update gets deleted
- React Hooks: state not updating when called inside Socket.io handler
- Problems when updating state in React
- React - unique key in object gets overwritten when updating state array
- react / redux toolkit useSelector not updating when store state changed
- React Recoil selector not triggering its get when the atom state updates to a previous value
- Ant design Form validation is not working and not updating input values when component is from a state that is passed from a function
- HighCharts not updating when the state changes in React
- React js - Updating state with array values and a line break
- React Updating Nested State Object deletes other values
- How to manage State values when cursor is moving fast over a component in React JS?
- React useState. Why do the docs advise passing a function with the previous state when setting the state?
- React update state only when button is clicked rather than updating whenever something is written in input
- React hooks get previous state of state A when setting state of state B
More Query from same tag
- Error dynamically adding table rows in reactJs
- Signing Up in Firebase Authentication returns null for displayName in React app
- React and Leaflet - issue displaying a layer
- React stop rerendering of parent component when slider is used
- Uncaught SyntaxError: Unexpected token '<' From ReactJS when behind Gateway (Reverse Proxy)
- How do I have a horizontal line around title in React. or CSS?
- How to verify store function call?
- The data fetched from an API doesn't populate the table in NextJS
- How to pass a value to this react component
- Can I use PropTypes to express that a prop is a Promise?
- Why the Grid Element Not Arranging The Typography
- How to get CSS style in snapshot with Jest
- How to render a React app in a React app (nested React apps)
- Display dynamic message for updates/releases on a react redux app
- React-Redux & Material UI: Component doesn't pass store to 'connected' child
- Can I use css modules and inline style together on React component in SSR?
- React : Passing and retrieving data between parent and child using props and callbacks
- How to fake the focus on a Material-ui TextField from a button click?
- Change body background with data-theme attribute on click with React
- Axios.delete in React: `Error:DELETE chrome-extension://...`
- ./node_modules/react-router-dom/node_modules/warning/warning.js Error: ENOENT: no such file or directory, open
- Nodejs - TypeError stating that the hashPassword function is not a function, how can I solve it?
- Passing 'this' to Axios promise 'then'?
- how to import a function from one component react to another component to render it?
- React: How to supply callback arrow functions to stateless functional child components?
- Submit nested form in Formik
- React: fetch call's then function not being called
- How can you tell if a request should render server side? (ReactJS)
- React JS Inheritance get data
- How to add validation in Material ui form input fields