score:2
one possible solution could be, usecallback hook. it will solve your problem of unnecessary re-rendering. i.e.
const [items, setitems] = usestate<t[]>([] as t[])
const loadprimarydata = usecallback(async () => {
const data = await fetchprimarydata();
setitems(data);
}, []);
const loadsecondarydata = usecallback(async () => {
for (const item of data) {
await secondaryrequest(item)
setitems([...data])
}}, [data]);
further, if you want to load data one after another, depending on your use-case, you can use useeffect hook.
Source: stackoverflow.com
Related Query
- Prevent Component Flicker in React State Update
- React hooks function component prevent re-render on state update
- How can I prevent a React state update on an unmounted component in my integration testing?
- React prevent change state in child component when parent component update
- Can't perform a React state update on an unmounted component
- React useEffect causing: Can't perform a React state update on an unmounted component
- React-hooks. Can't perform a React state update on an unmounted component
- Update component state from outside React (on server response)
- onChange event for React child component to update state
- How to update the state of a sibling component from another sibling or imported component in REACT
- Warning: Can't perform a React state update on an unmounted component. In a functional component
- React Apollo: Dynamically update GraphQL query from Component state
- useEffect - Can't perform a React state update on an unmounted component
- react component connected, redux state changes... but no update to component?
- React js changing state does not update component
- How to update React component after changing state through redux?
- Update a react state (array of objects) from a child component
- How to properly update a react native swiper component when state changes?
- How to test state update and component rerender after async call in react
- Error : Can't perform a React state update on an unmounted component
- Best way to update className based on react component state
- React component not updating on final dispatch and update of redux state
- How to update parent state from child component in React + send a paramater
- Too many re-renders. React limits the number of renders to prevent an infinite loop. Updating state of a functional component inside the render method
- Can't perform a React state update on an unmounted component with fetch POST method
- How does React update a component and its children after a state change?
- react-top-loading-bar Warning: Can't perform a React state update on an unmounted component
- Waiting for react state to update in function component
- How to update State Hook with onClick listener on React Component Instance
- Get state and update state in a non react component in nextjs
More Query from same tag
- Set state of react component before mount with firebase data
- How can I run an ajax call from another method in ReactJS?
- How to retrieve form elements with React's ref?
- Uncaught SyntaxError: Unexpected token export
- React getElementById TypeScript
- how to define string for .toLowerCase for filter search with multiple search items
- Type string[] is not assignable to type 'IntrinsicAttributes & string[]'
- Is there a way to change icons in the ant design image preview operations?
- How to format \n as a line break in my markdown returned via a GraphQL query
- Material UI Autocomplete: Display part of selection
- Basic React Tests Failing after Implementing Redux
- How to return a result properly from async/await function?
- Can't remove extra white space on my website
- Clear form after submit React
- react-axios handle error don't get the message from the server
- dependency tree error using create-react-app and storybook
- How to store new items in an array each time a component is rendered?
- Webpack "devtool eval" doesn't show correct files content in devtools
- Passing both the event and an argument to a handler in React
- How to apply mixpanel on event 'triggering' of dropdown in antdesign
- Uncaught TypeError: this is undefined in Amplify UI in React
- What is the best way to update redux from a child component?
- Calling functions after state change occurs in reactjs
- React setState array not getting sorted
- React React-router Invariant Violation: replaceState(...) Error
- Render is not updated?
- Fill in empty blocks for each calendar month JS
- How to Re-load ReactJS Component in Vanilla HTML / JS?
- Is it possible to call dom element methods like focus() without using a ref? (Stateless Component Functions)
- React display props on table from props.object