Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Move render function out of route handlers #1155

Merged
merged 1 commit into from
Jul 11, 2017
Merged

Conversation

el-mapache
Copy link
Contributor

This is a little POC to move ReactDOM.render calls out of the route handler functions and let React handle its own updates with a new RouteProvider component. The main benefit is that we don't have to re-render the MainContainer every time a route changes.

It also could set us up for integrating the router within the flux architecture if we want to do more of that in the future!

Let me know what ya'll think!

@el-mapache el-mapache self-assigned this Jul 7, 2017
@@ -57,10 +51,6 @@ export function overview(next) {
})
.then(pageActions.loadSuccess, pageActions.loadError);

ReactDOM.render(<MainContainer>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason, you removed it from here and moved it up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I had originally moved it inside the callback, which obviously blocked rendering, and when I moved it out stuck it above the spaceActions fetch call for no good reason 😄

@jcscottiii
Copy link
Contributor

I like it. just had one question.

@jcscottiii
Copy link
Contributor

One more question. do you think this pattern should go into the CONTRIBUTING guide? (do you think it's something other devs would be likely to not do this if they didn't read it?)

@el-mapache
Copy link
Contributor Author

I'm not sure, I suppose it depends on the future routes added and what the devs' rationale is at that point in time..and also if we all agree splitting the apps concerns this way is worth the changes.

@el-mapache
Copy link
Contributor Author

Seems like this change is at least not disliked by the team, so if someone wants to merge it that is 👍 !

Adds router store, actions, router jsx container

* decouple react DOM rendering from route handler
* stop triggering a full app repaint on every route change

Remove comments/old code, default show <Loading/>

Add RouteProvider component, restore next calls

Add spec for router actions

Also updates assertAction helper to look for presence of `data` key in
action dispatch

Add spec for RouterStore

Fix shouldComponentUpdate logic in RouteProvider

* It was always returning true

Add RouteProvider spec
@jcscottiii jcscottiii merged commit 9e19be0 into master Jul 11, 2017
@jcscottiii jcscottiii deleted the ab-router-poc branch July 11, 2017 14:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants