这一般是首页入口js
import {createStore, applyMiddleware} from "redux";
import {Provider} from "react-redux";
import thunk from "redux-thunk";
import {BrowserRouter} from "react-router-dom";
//使用react-thunk
//在prvider包围的组件里多了一个this.props.dispatch(dispatch,getstate)方法
const store = createStore(Reducers,applyMiddleware(thunk));
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>,
document.getElementById('root')
);
<App/> 组件是项目真正的逻辑组件,是在react-redux和react-router组件的内部。因此app的子组件都可以接收这两个组件传来的props。也就是这样用的啊,你不用传来的props安装这两个干嘛
class Details extends Component{
//父类接收参数然后又传给子组件,不行的话this.props中用不了react-router/react-redux的属性
constructor(arg){
super(arg)
//可以看到我们己经有了react-router和react-redux的属性了
console.log(this.props)
}
}