react-router icon indicating copy to clipboard operation
react-router copied to clipboard

Parent Context not propagated to children

Open albertoclarit opened this issue 11 years ago • 1 comments

I have the following router configuration

<Router history={history}>
        <Route path ="/" component={FrontendApp}>
            <Route path ="login" component={Login}/>
            <Route path ="unauthorized" component={Unauthorized}/>
            <IndexRoute component={Index}/>
        </Route>
        <Route path="/main" component={MainMenu}>
            <IndexRoute component={MainMenuIndex}/>
        </Route>
    </Router>

I am using Material Ui http://material-ui.com/#/ and one of the requirement is to define a theme in the parent context and it will automatically available to the children as well.

Declared at FrontendApp.js

  childContextTypes: {
            muiTheme: React.PropTypes.object
        },
        getChildContext: function() {
            return {
                muiTheme: ThemeManager.getCurrentTheme()
            };
        },

on Login.js

Any reference to this.context.muiTheme is null?

Im using V1.0.0RC I dont have this problem in V0.13.3

albertoclarit avatar Sep 25 '15 21:09 albertoclarit

You probably need to use React 0.14 to get parent-based context.

mjackson avatar Sep 25 '15 21:09 mjackson