0
這是我的app.jsx,我想訪問isAdmin
狀態Login Component
到app.js ... isAdmin
標識用戶是否是管理員,並基於值..我想操縱路線....我怎麼能做到這一點?訪問renderDOM中的組件狀態值
請幫助我新的反應......
import Login from './components/Forum/login';
console.log("login",Login.this.state.isAdmin);
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={Base}>
<IndexRoute component={isAdmin == true ? DashboardV1 : ChartFlot } />
<Route path="dashboard" component={DashboardV1}/>
<Route path="dashboardv2" component={DashboardV2}/>
<Route path="dashboardv3" component={DashboardV3}/>
<Route path="form-cropper" component={FormCropper}/>
</Router>,
document.getElementById('app')
);
但rectDOM.render我怎能用戶的單據? –
然後只需從Login組件導出函數isAdmin並在React Dom渲染中調用。 isAdmin函數內部是this.state.isAdmin。 –