这是结构这是相关代码 hello.jsimport React from 'react'import { connect } from 'react-redux'import { bindActionCreators } from 'redux'import * as actions from '../actions/action'import islogoin from '../components/islogoin'import detail from '../components/detail'class Hello extends React.Component { render(){ return( <div> <islogoin logininfo={this.props.logininfo} /> <hr/> <detail logininfo={this.props.logininfo} /> </div> ) } componentDidMount() { // 模拟登陆 this.props.action.login({ userid: 'abc', city: 'beijing' }) }}function mapStateToProps(state){ return { logininfo: state.loginlist }}function mapDispatchToProps(dispatch) { return { action: bindActionCreators(actions, dispatch) }}export default connect( mapStateToProps, mapDispatchToProps)(Hello)这是islogoinimport React from 'react'class islogoin extends React.Component { render() { const loginstate=this.props.logininfo.islogin if(loginstate=='no'){ return ( <p>Please sign up!</p> ) } else{ return ( <p>Welcome back!</p> ) } }}export default islogoin这是问题我是哪里写的不对么
添加回答
举报
0/150
提交
取消