What is react redux?

藏色散人
Release: 2019-05-05 16:19:19
Original
5275 people have browsed it

React-Redux is the official React binding library for Redux. It enables your React components to read data from the Redux store and dispatch actions to the store to update the data.

What is react redux?

Installation

Use React-Redux in your React app:

npm install --save react-redux
Copy after login

or

yarn add react-redux
Copy after login

In short In short, react-redux is a lightweight encapsulation library with only two core methods: Provider and connect.

React-Redux provides the component, which enables your entire app to access data in the Redux store:

import React from "react"; import ReactDOM from "react-dom"; import { Provider } from "react-redux"; import store from "./store"; import App from "./App"; const rootElement = document.getElementById("root"); ReactDOM.render(   , rootElement );
Copy after login

React-Redux provides a connect method that allows you to Components and stores are connected.

Usually you can call the connect method in the following way:

import { connect } from "react-redux"; import { increment, decrement, reset } from "./actionCreators"; // const Counter = ... const mapStateToProps = (state /*, ownProps*/) => { return { counter: state.counter }; }; const mapDispatchToProps = { increment, decrement, reset }; export default connect( mapStateToProps, mapDispatchToProps )(Counter);
Copy after login

Related recommendations: "javascript tutorial"

The above is the detailed content of What is react redux?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!