Can react-redux be injected into the entry file like vuex and store can be accessed anywhere?

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

clipboard.png

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;
Nov.19,2021

your Father component needs to connect with store


          <img style={{width:'200px',margin:'0 auto',display:'block'}} src={require('../logo.svg')} alt={'logo'} />
          <Head></Head>
          <Main></Main>
          <Footer></Footer>
        </div>
      )
  }
}
const mapStateToProps = (state) => {
    return {
        
    }
}
const mapDispatchToProps = (dispatch) => {
    return {
        
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Father)

Previous: Can you think of a page of Mini Program as a single-page application of vue?

Next: H5 page jumps to app so you can write it. I'm ios now, but I can't do Android.

Menu