reactjs - React Router: Call component function on RouteHandler ref -
i'm trying call component function on child component routehandler.
var bar = react.createclass({ baz: function() { console.log('something'); }, render: function() { return <div />; }, }); var foo = react.createclass({ baz: function() { this.refs['ref'].baz(); }, render: function() { return <routehandler ref="ref" />; }, );
where routehandler
bar
this.refs['ref'].baz
undefined
.
see https://facebook.github.io/react/tips/expose-component-functions.html more information on component functions.
i don't believe react-router supports exposing component functions on routehandlers , current hacky workaround do:
this.refs['ref'].refs['__routehandler__'].baz();
Comments
Post a Comment