Skip to content

Changed props not propagated to route handlers on subsequent renders #358

Closed
@nnarhinen

Description

@nnarhinen

Consider following code (live demo at http://jsfiddle.net/raem6o6z/)

var RouteHandler = React.createClass({
    render: function() {
        return React.DOM.div({}, this.props.foo ? 'Is foo' : 'Is not foo');
    }
});

var App = React.createClass({
    getInitialState: function() {
        return {foo: true};
    },
    componentDidMount: function() {
        var self = this;
        setTimeout(function() {
            self.setState({foo: false});
            console.log('setting state');
        }, 2000);
    },
    render: function() {
        return ReactRouter.Routes({},
                                  ReactRouter.Route({
                                      handler: RouteHandler,
                                      foo: this.state.foo
                                  }));
    }
});

React.renderComponent(App(), document.getElementById('app'));

After setting the state App::render is called as well as RouteHandler::render but the props on RouteHandler are not updated, they still point to the initial values.

Is this expected (documented?) behavior? And if so is there something I can do about it. I need to pass changed stuff to the route handlers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions