Skip to content
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

Add getRenderer method #5017

Merged
merged 5 commits into from
Apr 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/using-react-native-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"description": "Example usage of gatsby-plugin-react-native-web",
"author": "Sebastien Lorber <lorber.sebastien@gmail.com>",
"dependencies": {
"gatsby": "^1.9.221",
"gatsby": "^1.9.251",
"gatsby-link": "^1.6.37",
"gatsby-plugin-google-analytics": "latest",
"gatsby-plugin-react-native-web": "^0.1.2",
"gatsby-plugin-react-native-web": "^0.2.0",
"gatsby-plugin-react-next": "^1.0.11",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-native-web": "^0.5.1"
"react-native-web": "^0.6.0"
},
"devDependencies": {
"babel-plugin-react-native-web": "^0.5.1"
"babel-plugin-react-native-web": "^0.6.0"
},
"license": "MIT",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions packages/gatsby/cache-dir/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ apiRunnerAsync(`onClientEntry`).then(() => {
Root = Root.default
}

const renderer = apiRunner(`replaceHydrateFunction`, undefined, ReactDOM.render)[0]

domReady(() =>
ReactDOM.render(
renderer(
<HotContainer>
<Root />
</HotContainer>,
Expand All @@ -57,7 +59,7 @@ apiRunnerAsync(`onClientEntry`).then(() => {
if (NextRoot.default) {
NextRoot = NextRoot.default
}
ReactDOM.render(
renderer(
<HotContainer>
<NextRoot />
</HotContainer>,
Expand Down
5 changes: 4 additions & 1 deletion packages/gatsby/cache-dir/production-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,11 @@ apiRunnerAsync(`onClientEntry`).then(() => {
)

const NewRoot = apiRunner(`wrapRootComponent`, { Root }, Root)[0]

const renderer = apiRunner(`replaceHydrateFunction`, undefined, ReactDOM.render)[0]

domReady(() =>
ReactDOM.render(
renderer(
<NewRoot />,
typeof window !== `undefined`
? document.getElementById(`___gatsby`)
Expand Down
10 changes: 10 additions & 0 deletions packages/gatsby/src/utils/api-browser-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ exports.replaceHistory = true
* @param {object} $0.Root The "Root" component built by Gatsby.
*/
exports.wrapRootComponent = true

/**
* Allow a plugin to replace the ReactDOM.render function call by a custom renderer.
* This method receives the same parameters as ReactDOM.render takes.
* Note it's very important to call the provided callback after rendering, otherwise Gatsby will not be able to call `onInitialClientRender`
* @param {object} $0 element
* @param {object} $1 container
* @param {object} $2 callback
*/
exports.replaceHydrateFunction = true