Last active
July 11, 2018 09:56
-
-
Save Rendez/b6e7834de37cce367e2cf8b718ec8bc3 to your computer and use it in GitHub Desktop.
Revisions
-
Rendez revised this gist
Jul 11, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,6 @@ class SSRComponent extends React.Component { throw new Error('Cannot set state in a server-side-rendered component'); } forceUpdate() { throw new Error('Cannot update in a server-side-rendered component'); } } -
Rendez created this gist
Jul 11, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ const unexpectedLifecycleMethods = ['componentDidMount', 'componentDidUpdate', 'componentWillUpdate', 'UNSAFE_componentWillUpdate', 'componentShouldReceiveProps', 'UNSAFE_componentShouldReceiveProps']; class SSRComponent extends React.Component { constructor(...args) { super(...args); unexpectedLifecycleMethods.forEach((methodName) => { if (this.hasOwnProperty(methodName)) { throw new Error(`Cannot declare '${methodName}' in a server-side-rendered component`); } }); } setState() { throw new Error('Cannot set state in a server-side-rendered component'); } forceUpdate() { throw new Error('Cannot set state in a server-side-rendered component'); } }