This repository has been archived by the owner on Jan 2, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Supports async routes by utilizing `match` for the initial client render if server-side rendering is enabled * Uses `require` provided by `require.ensure` * Renames parameters from `props` to `options` * fix(client): Always render asynchronously to the DOM to allow code splitting * style(lint): Use proper JSON formatting
- Loading branch information
1 parent
0ff7baa
commit 5c7db39
Showing
7 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React, { Component } from 'react'; | ||
|
||
export default class Async extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
Such asynchronously rendered! | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
extensions/roc-package-web-app-react/app/client/render-to-dom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable global-require */ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Router from 'react-router/lib/Router'; | ||
import match from 'react-router/lib/match'; | ||
|
||
function renderSync({ renderProps, createComponent, routerRenderFn }, node) { | ||
const finalComponent = createComponent( | ||
<Router | ||
{...renderProps} | ||
render={routerRenderFn} | ||
/> | ||
); | ||
|
||
ReactDOM.render(finalComponent, node); | ||
} | ||
|
||
export default function renderAsync({ history, routes, ...rest }, node) { | ||
match({ history, routes }, (error, redirectLocation, renderProps) => { | ||
renderSync({ | ||
...rest, | ||
renderProps, | ||
}, node); | ||
}); | ||
} |