can react-redux be injected into the entry file like vuex and store can be accessed everywhere? The novice
code is as follows:
if I need to access the store component, I need to add < Provider store= {store} > {children} < / Provider >
and create createStore
within the father component, access store is undefind
import React from "react";
import { Provider } from "react-redux";
import { createStore } from "redux";
import CounterReducer from "../reducers/CounterReducer";
let store = createStore(CounterReducer);
export default ({ children }) => <Provider store={store}>{children}</Provider>
index.js
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<Father />
</BrowserRouter></Provider>,
document.getElementById("root")
);
father.js
import React, { Component } from "react";
import Head from "./Head";
import Main from "./Main";
import Footer from "./Footer";
class Father extends Component {
render() {
console.log(this.store);
return(
<div className="my-app">
<img style={{width:"200px",margin:"0 auto",display:"block"}} src={require("../logo.svg")} alt={"logo"} />
<Head></Head>
<Main></Main>
<Footer></Footer>
</div>
)
}
}
export default Father;