import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import store from './redux/count_redux/store'
ReactDOM.render(
// React.StrictMode检查app和app包裹的组件是否合理
<BrowserRouter>
<Provider store={store}>
<App />
</Provider>
</BrowserRouter>,
document.getElementById('root')
);
在index.js中使用provide,provide上直接使用store,容器组件得到store,避免多个ui组件上调用store,不然就需要逐一的在ui组件标签上引入store,例如如下:
import Login from './components/Login'
import Register from "./components/Register"
import store from './redux/store'
function App() {
return (
<div>
<Login store={store}/>
<hr/>
<Register store={store}/>
</div>
);
}
export default App;