提交 4421448f 编写于 作者: G Gerald Monaco 提交者: Tim Neutkens

Add `StrictMode` toggle (#9161)

* Add StrictMode toggle

* Rename option to reactStrictMode

* Default to false initially
上级 be42300e
......@@ -736,6 +736,9 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_PRERENDER_INDICATOR': JSON.stringify(
config.devIndicators.autoPrerender
),
'process.env.__NEXT_STRICT_MODE': JSON.stringify(
config.reactStrictMode
),
...(isServer
? {
// Fix bad-actors in the npm ecosystem (e.g. `node-formidable`)
......
......@@ -372,11 +372,19 @@ async function doRender ({ App, Component, props, err }) {
appProps
})
// We catch runtime errors using componentDidCatch which will trigger renderError
renderReactElement(
const elem = (
<AppContainer>
<App {...appProps} />
</AppContainer>,
</AppContainer>
)
// We catch runtime errors using componentDidCatch which will trigger renderError
renderReactElement(
process.env.__NEXT_STRICT_MODE ? (
<React.StrictMode>{elem}</React.StrictMode>
) : (
elem
),
appElement
)
......
......@@ -53,6 +53,7 @@ const defaultConfig: { [key: string]: any } = {
},
serverRuntimeConfig: {},
publicRuntimeConfig: {},
reactStrictMode: false,
}
const experimentalWarning = execOnce(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册