![](/img/trans.png)
[英]How can I set the state of my parent component from the child component when using react-router?
[英]Expose child component functions to parent with ref using react-router
此鏈接描述了如何在組件上設置引用並從父對象調用其函數: https : //facebook.github.io/react/tips/expose-component-functions.html
當我使用react-router並且我要引用的組件是路由而父級是根組件時,如何實現此目的?
這有效:給<RouteHandler/>
引用,例如: <RouteHandler ref="routerHandler"/>
然后像這樣調用: this.refs.routerHandler.refs.__routeHandler__.someFunctionOnActiveRoutesHandler()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.