score:2
I assume that you dispatch FETCH_REQUEST
action creator from your component. This component probably receives userList
as a property. So this component is the best place to determine whether FETCH_REQUEST
action should be dispatched.
Something like this:
class MyComponent extends React.Component {
componentDidMount() {
if (!this.props.userList) {
this.props.fetchData();
}
}
}
...
export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);
In this case you don't need to use a selector and extra condition in your saga.
Source: stackoverflow.com
Related Query
- Redux saga - the point to skip API requsts if data already exists in redux store
- How can I cache data that I already requested and access it from the store using React and Redux Toolkit
- React skip API request if data already exists
- React, Redux Saga using Typescript hitting 1 API Point to get paginated and non paginated data
- Is it good to store all the fetched data from api call in redux store?
- What's the point of normalizing api responses in a Redux app?
- How to fetch data in getInitialProps with redux-saga.Then get the response from redux store while in the getInitialProps method?
- Redux / Redux Saga - how to wait for the store to update?
- How to generate a unique id automatically for the data that is posted to an API server using axios library in redux
- Redux saga not calling the API
- Fetching data from store if exists or call API otherwise in React
- Loading Data from MongoDB into Redux Store fetching from my node API
- performance: connecting to the Redux store vs passing data through props
- Prevent API call if data present in redux store
- Append data to the nested redux store
- How to get the data from Redux store using class components in React
- How to push the data from api to my initial state list items using the redux toolkit?
- What is the correct way to React Hook Fetch Api and store to Redux and retrieve it with Selector immediately?
- Should I use the Redux store to pass data from child to parent?
- Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware with redux tool
- I am trying to load data from redux store on click and updating the state, but the data from state is not getting updated on the click
- Does not show API fetch response data in the page - React Redux
- How to set state at the server for data from API using react redux
- Unable to load the store in redux with some static data
- get data from an api and store it in a state, but the state still shows undefined
- TypeScript with Redux. Redux Saga How to wait for the LOAD_SUCCESS to return and save your data for later use
- Axios with Redux Saga not sending form data when insert and put to nodeJs+express api
- How to prevent loading state in Redux toolkit if the data has already been fetched
- Redux tool kit error Error: Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware
- How can I fetch data from an array of objects, pass it through an API end point to .fetch() the needed object value using React?
More Query from same tag
- <Grid> in Material UI - Items overlap to the right, when reducing the screen-size -> not using the left-side
- How would I return an error message upon a failed search in react.js
- Why does a test fail when using findBy but succeed when using waitfor?
- why i'm not able to fetch api?
- How to Use Select Multiple with Redux Form?
- How do I implement a hamburger dropdown in my React navbar
- Typescript and destructured variables not recognising props
- Updating state inside nested array when mapping the parent
- how can i put the selected state in tree data by first render
- How to Use Tableau WDC in a ReactJs app the correct way
- How to fetch only part of a Firebase RealTime database, and not the entire database?
- Trouble with the AuthContext component after using a private route with it
- Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
- Object becomes a string after accessing it
- How to dispatch a value from Textarea to store React Redux
- Why is the wrong index assigned?
- Navigating directly to URL in Single Page Node App Results in 404
- Rendering react components multiple times based on cookies
- How to use dropzone in a single file mode?
- in react native app get location and call a state updating function
- Test React/Redux component with Jest
- Why callback function in react-dnd useDrop hook can't update parent component state?
- useeffect() run and set data to the variable after the return() run in react? how to handle this?
- Is it possible to use material-ui button navigation with react-router?
- 'Keypress" event called twice when using arrow function notation
- Conditional styling with Styled Components
- How to set image background to div using css
- Testing hooks with renderHook
- Handle Event With React Functional Component - Receiving Not Defined Error
- Getting undefined instead of Input Field value