diff --git a/lib/side-effect.js b/lib/side-effect.js index 4ca5b5af..e6c6c6f6 100644 --- a/lib/side-effect.js +++ b/lib/side-effect.js @@ -58,10 +58,15 @@ export default function withSideEffect (reduceComponentsToState, handleStateChan constructor (props) { super(props) + if (!SideEffect.canUseDOM) { + mountedInstances.add(this) + emitChange(this) + } + } + componentDidMount () { mountedInstances.add(this) emitChange(this) } - componentDidUpdate () { emitChange(this) } diff --git a/test/integration/basic/pages/dynamic/head.js b/test/integration/basic/pages/dynamic/head.js new file mode 100644 index 00000000..59229e02 --- /dev/null +++ b/test/integration/basic/pages/dynamic/head.js @@ -0,0 +1,24 @@ +import dynamic from 'next/dynamic' +import Head from 'next/head' + +const Test = dynamic({ + loader: async () => { + // component + return () => { + return
+ +