-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 uniform wrapPageElement and wrapRootElement apis to SSR and Browser #7204
Conversation
… input for another
Deploy preview for using-postcss-sass failed. Built with commit e50552b https://app.netlify.com/sites/using-postcss-sass/deploys/5b754edbdd28ef648dced780 |
Deploy preview for gatsbygram ready! Built with commit e50552b |
Deploy preview for using-drupal ready! Built with commit e50552b |
Deploy preview for gatsbyjs failed. Built with commit e50552b https://app.netlify.com/sites/gatsbyjs/deploys/5b754edadd28ef648dced774 |
Deploy preview for using-styled-components failed. Built with commit b1625e2 https://app.netlify.com/sites/using-styled-components/deploys/5b74c472fdd72a20a5f6639c |
Deploy preview for using-contentful failed. Built with commit b1625e2 https://app.netlify.com/sites/using-contentful/deploys/5b74c473fdd72a20a5f6639f |
Deploy preview for using-glamor failed. Built with commit b1625e2 https://app.netlify.com/sites/using-glamor/deploys/5b74c471fdd72a20a5f66399 |
Deploy preview for using-jss failed. Built with commit b1625e2 https://app.netlify.com/sites/using-jss/deploys/5b74c475fdd72a20a5f663b7 |
Deploy preview for image-processing failed. Built with commit b1625e2 https://app.netlify.com/sites/image-processing/deploys/5b74c471fdd72a20a5f66396 |
}, | ||
wrapRootComponent: { | ||
replacement: `wrapRootElement`, | ||
migrationLink: `https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/#browser-api-wraprootcomponent-was-removed`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: setup short link once this is merged
…s done in node env now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic! Only found a few copy nits that need corrected. Super excited for this to land!
docs/docs/migrating-from-v1-to-v2.md
Outdated
@@ -874,6 +895,26 @@ Import graphql types from `gatsby/graphql` to prevent `Schema must contain uniqu | |||
+const { GraphQLString } = require(`gatsby/graphql`) | |||
``` | |||
|
|||
### Browser API `wrapRootComponent` was removed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe say, "was replaced with wrapRootElement
"?
|
||
Wrap pages in component that won't get remounted on page changes. | ||
|
||
Wrapping component will have access to all props available in Page components. This is escape hatch to get basic v1 layouts back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing an "an" — "This is a escape"
) | ||
``` | ||
|
||
And then You can use it anywhere: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lower case y in you.
Add mention in layout removal section in migration guide pointing to |
Glad to see this wrapping up, I've been waiting to get this into my site! Thanks for the hard work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕺
…er (gatsbyjs#7204) * Remove not used API hook * save browser plugin names in development to identify plugins * update using-redux example * allow ssr and browser api runners to use return of previous plugin as input for another * allow chaining of browser wrapRootComponent api * add chainable wrapRootComponent api to ssr * api docs corrections * add wrapPageComponent to both ssr and browser APIs * update replaceRouterComponent migration section * add migration guide section on wrapRootComponent signature change * add example to wrapPageComponent / wrapRootComponent * add link to migration guide in console error * update gatsby-plugin-jss * styletron plugin and example update * add gatsby-plugin-layout * update styled-components plugin * add using-multiple-providers-example * fix lint * add some clarification to docs * gatsby-plugin-layout version sanity check + readme update * let preferDefault do its jon - thanks porfirioribeiro * rename wrapXcomponent to wrapXelement * update migration guide * migration guide docs update * add console warning when wrapRootComponent is used with link to migration guide * [gatsby-plugin-layout] default to `src/layouts/index.js` * update gatsby-plugin-layout readme with default settings * [gatsby-plugin-layout] proper version syntax * use shortlink * no need for plugin name, in browser requires list - migration check is done in node env now * typos * migration guide section rename * link to gatsby-plugin-layout in layout component removal section * missed typo
* Part of #7204 Also added in some language from a quick review. Signed-off-by: moxiegirl <[email protected]> * Responding to @amberleyromo comment Signed-off-by: moxiegirl <[email protected]> * tweaks
* Part of gatsbyjs#7204 Also added in some language from a quick review. Signed-off-by: moxiegirl <[email protected]> * Responding to @amberleyromo comment Signed-off-by: moxiegirl <[email protected]> * tweaks
We are missing proper hooks and method to wrap either Page components (to restore layout, get some transition solution using plugins) or Router/Root components (to setup Providers) that can be used in both SSR and Browser envs.
Because of that other APIs were missused and their restrictions often caused problems (like limitation to single use of API).
This adds:
wrapRootElement
to both gatsby-ssr and gatsby-browserwrapPageElement
to both gatsby-ssr and gatsby-browserwrapRootElement
andwrapPageElement
hooks are chainable - meaning more than 1 plugin can use them.wrapRootComponent
is getting removed in favour ofwrapPageElement
- It also slightly modifies signature ofwrapRootComponent
, which now should be simpler - return componets and not function that returns components. Also because it is now chainable -Root
react component is no longer passed - nowcomponent
Element is passed which is instance of react component - this was done mainly because I wanted to keep signatures of new APIs as close as possible and this way we won't have to pass page props to components we know nothing about inwrapPageComponent
- it's enough that we use component instance that is already created.Because of this change I added some checks in development - there is still TODO to add this change to migration guide, generate short link and link to it.
This is first part of resolution for #6127