Expose child component functions to parent with ref using react
This link describes how you can set a ref on a component and call its functions from a parent: https://facebook.github.io/react/tips/expose-component-functions.html
How do i achieve this when i'm using react-router and the component I want to ref is a route and the parent is the root component?
This works: Give <RouteHandler/>
a ref, like this: <RouteHandler ref="routerHandler"/>
Then call like this: this.refs.routerHandler.refs.__routeHandler__.someFunctionOnActiveRoutesHandler()
上一篇: ES6 + React组件实例方法
下一篇: 使用反应,将子组件函数公开给ref