0
遞給
我有以下我最頂端的部分應用中呈現功能:Reactjs送道具的孩子,從路線
render() {
const { content } = this.props;
return (
<div id="content">
{content}
</div>
)
}
的{內容}變量是從路由傳遞這樣的:
export default (
<Router history={History}>
<Route path={UserConstants.HOME_ROUTE} component={App}>
<IndexRoute components={{content:HomePage}}/>
<Route path={UserConstants.LOGIN_ROUTE} components=}{content:LoginPage}} />
</Router>
)
如何從父應用添加道具到{content}?
這個作品有點可以使這更動態的不同的子組件協同工作。內容組件加載,但沒有生命週期事件觸發其父項給予的道具。 ComponentWillUpdate/DidUpdate或Mount對prop沒有任何幫助... – Stefan
好吧,它現在可以工作。謝謝。 – Stefan