Skip to content

Confused about partial-app-loading #1080

New issue

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

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

Already on GitHub? # to your account

Closed
EvHaus opened this issue Apr 14, 2015 · 5 comments
Closed

Confused about partial-app-loading #1080

EvHaus opened this issue Apr 14, 2015 · 5 comments

Comments

@EvHaus
Copy link

EvHaus commented Apr 14, 2015

I've used the partial-app-loading example to build a similar process in my app, but now I'm seeing this warning message in the console:

Warning: Don't set .props.activeRoute of the React component <RouterComponent />. Instead, specify the correct value when initially creating the element.

Is the example out of date? Is there another way I should be setting the RouteHandler? The example shows the code as:

// Can't find RouteHandler in the loaded component, so we just grab
// it here first.
this.props.activeRoute = <RouteHandler/>;
return <Component {...this.props}/>;
@EvHaus EvHaus closed this as completed Apr 20, 2015
@EvHaus EvHaus reopened this Apr 20, 2015
@rgrwkmn
Copy link

rgrwkmn commented Apr 20, 2015

Make a new object from your props and set activeRoute. The error is from React because it doesn't want you to set this.props, they should only be passed into the component from a parent.

var props = this.props;
props.activeRoute = <RouteHandler/>;
return <Component {...props}/>;

@EvHaus
Copy link
Author

EvHaus commented Apr 20, 2015

@rgrwkmn That didn't help. Still getting the warning message.

@rgrwkmn
Copy link

rgrwkmn commented Apr 20, 2015

Ah, right, you need to actually make a new object, just setting it to another variable still references this.props. If you use underscore or something like it, this works:

var props = _.extend({}, this.props);
props.activeRoute = <RouteHandler/>;
return <Component {...props}/>;

@EvHaus
Copy link
Author

EvHaus commented Apr 20, 2015

That did the trick.

Should I keep the issue open so the official example code can be updated?

@ryanflorence
Copy link
Member

go check out the new huge-apps example, partial-app loading just got amazing on master (1.0 API)

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

No branches or pull requests

3 participants