react-redux遇到的问题

    let data = [
    {
        name:"aaa",
        gender:1,
        birthday:"1999-07-23",
        hobby:'篮球'
    },
    {
        name:"bbb",
        gender:1,
        birthday:"1999-10-02",
        hobby:'链球'
    }
]

// Reducer
function counter(state = data, action) {
  switch (action.type) {
    default:
      return state
  }
}

const store = createStore(counter)

// Map Redux state to component props
function mapStateToProps(state) {
  return {
    value: state
  }
}

// Map Redux actions to component props
function mapDispatchToProps(dispatch) {
  return {
    onAddClick: () => dispatch({type:"ADD"})
  }
}

const App = connect(
  mapStateToProps,
  mapDispatchToProps
)(RootRouters)

ReactDOM.render(
    <Provider store={store}>
    <App />
  </Provider>,
    document.getElementById('root')
)
react-router的代码如下:
export default class RootRouters extends React.Component {
    render(){
        return (
            <Router history = {browserHistory} >
                <Route path ="/" component={Header} >
                    <IndexRoute component={Home} />  
                    <Route path ='add' component={Add} />  
                    <Route path ='edit' component={Edit} />  
                    <Route path ='list' component={List} />
                </Route>
            </Router>
        )
    }
}

如果我的子组件比如Home要获取state状态该怎么获取,求指教
阅读 2k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题