import { Provider } from 'react-redux';
import store from './store/index';
<Provider store={store}>
<App />
</Provider>
2."react-redux"核心包为我们提供的钩子函数
const student = useSelector(state => state.student)
console.log(student.age);
import { useDispatch } from "react-redux";
const dispatch = useDispatch()
引入切片页面中暴露的action创建器(例如setName、setAge等),然后作为调用dispatch时的参数即可
import { setName,setAge } from "./store";
const nameHandler = () => {
dispatch(setName({name:'杨玉蝉'}))
}