一、介绍
React-Redux
是Redux
的官方React
绑定库。它能够使你的React
组件从Redux store
中读取数据,并且向store
分发actions
以更新数据
二、项目搭建
1.react项目搭建 npx create-react-app app
2.安装redux npm i redux
3.安装 react-redux npm i react-redux
三、项目使用
①React-Redux 提供<Provider/>
组件,能够使你的整个app访问到Redux store
中的数据:
src/index.js
import React from "react";
import { createRoot } from 'react-dom/client'
import App from './App.jsx'
// 引入
import store from './store'
// 引入