簡體   English   中英

使用react-router將帶有ref的子組件功能公開給父組件

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM