Skip to content

Handling Routing State Across Multiple Containers #954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quidmonkey opened this issue Mar 13, 2015 · 1 comment
Closed

Handling Routing State Across Multiple Containers #954

quidmonkey opened this issue Mar 13, 2015 · 1 comment

Comments

@quidmonkey
Copy link

Let's say I have a simple App:

    render: function () {
        return (
            <div id="app">
                <Header></Header>
                <Content></Content>
            </div>
        );
    }

Both my header and content need to change based on the current route.

I can think of one way of doing it by creating state containers for each route:

var routes = (
    <Route name="app" handler={App} path="/">
        <Route name="state1" handler={State1} />
        <Route name="state2" handler={State2} />
    </Route>
);

var State1 = React.createClass({
    getInitialState: function () {
        return {
            data: {
                headerthings: 'foo',
                contentthings: 'bar'
            }
        };
    },

    render: function () {
        return (
            <Header things={this.state.data.headerthings} />
            <Content things={this.state.data.contentthings} />
        );
    }
});

But this seems less than ideal, as I'm having to manually manage all the routing state myself. What's the best way to handle this?

@ryanflorence
Copy link
Member

#1008

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants