score:0
async in useeffect
should be considered an antipattern (here an explanation) and you should get a warning like warning: an effect function must not return anything besides a function, which is used for clean-up.
.
not only but your useeffect
has a missing dependency: listsomedatahandler
.
in this case, much better call an async function inside the useeffect
(and move listsomedatahandler
inside useeffect
). so your code becomes:
useeffect(() => {
const listsomedatahandler = async (status) => {
await listsomedata(status);
};
(async () => {
promise.all(
loadedstatus.map((status) => {
return listsomedatahandler(status);
})
);
})();
}, [loadedstatus]);
here i made a codesandbox example and, as you can see, listsomedatahandler
will be called 5 times.
Source: stackoverflow.com
Related Query
- How to call same query multiple times using apollo client in react js on first mount
- Trigger same query multiple times with apollo client fetchMore Apollo Client and append the data
- How to update state multiple times on same event using React useState hook?
- How to run multiple mutations in parallel using Apollo Client and GraphQL HoC?
- How to Handle Redirecting to the Same Route (with Query Params) Using React Router v4
- How to call onEnter function on Route in React Router Multiple times
- Apollo Client - How to test a component that uses multiple queries, using HOC components that use compose
- Props mix when using the same component multiple times on a page in React
- Multiple Queries using Apollo Client and React
- React App Using the same function in two places but the API call is different. How do I force it to use the root everytime?
- How to set multiple states using one response from axios API call in React
- How to render multiple items from an API call using React
- How to make a GraphQL lazy query with Apollo client after the first query is successful
- How to query the same Firestore data in multiple React components efficiently?
- How to fetch sequence api calls where second api call need particular data from first api call result using react hooks?
- How do you replace data multiple times with an array of keys using a react hook?
- How to call apollo client useQuery in react router?
- How to fix multiple call fetch data in forEach() using React Hooks
- how to render multiple line charts - highcharts on same page using highcharts react wrapper - highcharts-react-offical
- How to call an API with multiple pages using react
- How to make a second api call with data received from the first api call in Apollo client with React?
- React query used multiple times in same component
- How can i get errors out of Apollo client in a React front end using GQL
- How to apply the same method multiple times to different array elements using a key?
- What happens when using this.setState multiple times in React component?
- How to create multiple page app using react
- Apollo GraphQL React - how to query on click?
- How to query by text string which contains html tags using React Testing Library?
- use query hook react Apollo conditional call
- react native how to call multiple functions when onPress is clicked
More Query from same tag
- Getting this error , when trying to upload images through a form "TypeError: Cannot read property 'originalname' of undefined "
- ReactJS/Redux: Testing reducer state with array of objects inside receives undefined array
- React If / else for picture src
- React multiple checkbox with one check at a time
- Routing problem in React-JS / react-router-dom
- How to pass the default value back as input value if you don't want the value to be changed?
- Separate Log In page using HashRouter in React
- How to change the word into icon in Show/Hide in ReactJs
- How to make the span text not to be pushed to next line based on the preceding span element content using css?
- React.js How can I convert string base64 to normal image
- How to check a token in authentication
- How to show random items in an array of 6 items ReactJS and React Hook and reshuffle the array
- Inheritence - CSS Modules in React and Webpack
- Type 'number' has no properties in common with type 'XrangePointOptionsObject'.ts - React
- How do I hide an element if flash has not been detected in React JSX
- Sending parameter to Link to a Router component Reacts
- How to make texts appear below icons in Buttons (Material UI)
- Reactjs: how to keep a selected item state in the pagination? React-hooks
- How to use Spacy NLP from within a website
- Hello! I'm trying to make a chart with a json received from backEnd, and I can't parse it
- Not able to display fetched data on page, React JS
- a Textfiled does not use functions on props
- Render user input in a different component in React
- React: setting up firebase auth with firebase-ui
- Is it possible to make initial state empty object in React?
- How to add an event handlers to JSX node by event name?
- Cannot display switch in tabs in material-ui
- How to use a third-party API inside next/api?
- How to alert when Session (JWT) has expired in React/Redux
- How to clear interval in functional component if interval is set in a function?