score:1
Accepted answer
I believe you need to use connect
and mapStateToProps
for this requirement.
What we need to do is use connect function from react-redux
, your component would look something like this -:
import { connect } from "react-redux";
import {Component} from "react";
class YourComponent extends Component {
constructor(props){
super(props);
this.state = props.data;
}
// Your component code.....
}
export const mapStateToProps = state => ({
data: state.data,
});
export default connect(mapStateToProps)(YourComponent);
score:2
Once you have hooked up your redux store into your react application, using the approach recommended by @Abhisar. Your component automatically watches your state for changes and re-renders whenever there is a change in your redux state.
Also, see the official React Redux Doc
Source: stackoverflow.com
Related Query
- In a react components, how to get latest data from state once it is changed from another component using redux?
- React - How to get state data from a child component?
- How to get the data from Redux store using class components in React
- How to get state from two child components in React
- How to reload page once state or data is changed within a react class using component did mount
- In React components implemented with hooks, how can the latest component state values be read from within setInterval?
- how to get data from localstorage and set state react
- How to get the data from React Context Consumer outside the render
- How to get values from child components in React
- How can I get data from a local file into my React app?
- How to get form data from input fields in React
- how to import data in react from a js file to use in components
- How to get the changed state after an async action, using React functional hooks
- How do I access data returned from an axios get to display on a web page using react js?
- How to extract data to React state from CSV file using Papa Parse?
- How do I manage state on a React component that can have state changed from the parent or from events upon it?
- How can i get array of object from this data for state and count in reactjs
- I can not get the state from react router Link component using useLocation. So how can I pass it?
- How to get data from react context
- How do I correctly add data from multiple endpoints called inside useEffect to the state object using React Hooks and Context API?
- How can I get data from query string using route in react js
- How to Assign react redux state api get data using axios
- How to fix the state update in react while getting data from firestore database
- How to get data from an API only once when the page is loaded using axios.get method?
- React Dynamically download Components and get data from all child components
- How do I create dynamic forms which can be changed from state in react js?
- How do i pull data from redux state in react
- How to get data from table row click using Semantic's React Table Component
- How get data from the state and edit the element in the form?
- How to access data from get request made by a React functional component to localhost server using Axios?
More Query from same tag
- How does object spread notation transform react redux props?
- React-select - Is there a way to load values only on typing the characters
- How to prevent react from re-rendering the whole component?
- How to send file from React/Next.js client UI to Node server and next to Flask service
- How to render multiple modals in react?
- react.js wrong resuilt when converting timestamp to date
- Enzyme/Mocha: How to test a react component function by firing an onChange event from a child component
- How to use Radio Button in React Hook Form v7?
- Missing the location, history and match properties when combining custom props with RouteComponentProps
- React JS class component const = with multiple conditions
- .map is not getting re-rendered after updating the state
- How to set border-radius to ant design Select component
- How to create a new object from parent/child relationships using recursive JavaScript map method
- Using reduce on map of array to calculate difference between values
- Nested components with React Router
- How to add or remove a className when screen size change in react
- react-router-bootstrap linkcontainer
- Switching between 2 table objects in React JS
- Dealing with React Router on Apache server
- How to display certain elements of a list as sticky elements without adding any hierarchy in rendering?
- How to pass img src as a parameter in a stateless function in next js?
- How to create a trigger function that runs whenever the state changes?
- About convert object
- Conditional render + add some extra code in React
- import svg files inside meteor
- Does React have something similar to Angular's *ngIf?
- React ref using reactstrap Input Module doesn't have Value prop
- Error: <Route> elements are for router configuration only and should not be rendered in react-router v4
- How to change zIndex in react-select drowpdown in a way that the react-calendar component does not overlap? previous questions did not work
- Flask and React - Handling tokens after Spotify Authorization