score:1
you have the access to to get state in the return function, throught redux-think. so you can do something like this
export function fetchdata() {
return (dispatch, getstate) => {
posts.on('value', snapshot => {
dispatch({
type: fetch_data,
payload: snapshot.val()
});
// dispatch only if payload is different from the data in store
//get store state data here getstate() will give you full state
const data = getstate().pathtoyourdata
// write a helper function let says aresame and compare both the values
if (aresame(data, snapshot.val())) {
dispatch({
type: data_properties,
payload: object.keys(snapshot.val()),
});
}
});
};
}
Source: stackoverflow.com
Related Query
- React redux middleware. Compare payload to store before dispatch
- React redux dispatch action before render container
- React Redux - quick flash of previous state before dispatch issue
- React Redux dispatch payload reaches case with data but doesnt save it
- How to dispatch Redux store data without having to receive it in a React component?
- React Redux : use Selector is called before dispatch
- Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware with redux tool
- How to dispatch a value from Textarea to store React Redux
- React native + redux populate store with data before any Component render
- Redux tool kit error Error: Before running a Saga, you must mount the Saga middleware on the Store using applyMiddleware
- React Redux Store values immediatly after dispatch
- How to send component's state as payload to store in React redux
- Empty Redux store when attempting to dispatch from outside React component
- What is the best way to access redux store outside a react component?
- When do I choose React state Vs Redux Store
- Accessing Redux Store from routes set up via React Router
- React get state from Redux store within useEffect
- React Redux dispatch action after another action
- React Redux Store updating, but component not re-rendering
- What is the necessity of "export default connect" when you are connecting your react component to redux store
- How do I use local state along with redux store state in the same react component?
- React Redux unexpected key passed to create store
- Where to store WebRTC streams when building React app with redux
- Access Redux store outside React when using next-redux-wrapper
- Order of multiple middleware in React Redux
- React Native: HeadslessJS and Redux - How to access store from task
- Dispatch a Redux action with the subsequent action as payload to show a snackbar or dialog of Material UI
- React and Redux: Managing Redux Custom Middleware List
- React Redux - Why mapStateToProps is called before constructor?
- How to connect simple Formik form with Redux store and dispatch an action?
More Query from same tag
- React - How to get the button element I clicked?
- How to filter an array and remove duplicated elements?
- How to show a tooltip when specific rows of react DnD table are begin to be dragged in antd?
- useState Hook not updating properly
- how to set HSTS header in create-react-app
- React app HashRouter not working on localhost as well as Github User page
- Node mailer not sending emails
- Focus on (scroll to) a DIV element in React
- How to fetch data during react router transition?
- Multiple recursive <tbody> in same <table>?
- TypeError: Cannot read property of undefined | ReactJS
- How to change update an object within a useState array
- React Bind to const outside Class
- useDebugValue not Displayed
- <select> html tag wont visible same in chrome and safari
- GatsbyJS renders URLs incorrectly
- React, looping through object, displaying list, and grabbing that object when selected
- Add Google Analytics to Nextjs app with next-redux-wrapper
- configuring package.json on windows
- can we update an atom state whenver another atom changes in RecoilJS
- How to retain state of previous page while navigating back to it from another page?
- Why formData does not take the data there is in the state and that has been refreshed, there is a delay character ? React
- How to calculate current scroll position in list?
- MUI responsive Tabs
- Integrating Strophe with React JS
- React Route protection with HOC PrivateRoute component with asynchronous jwt token validation
- Add a Mapbox marker on double click event using React
- how to make a react component state change on window resize?
- Use case for useLayoutEffect + useState vs useMemo
- Avoid re-render with `useCallback`