refactor(react): throw an error if misconfigured in SSR mode

This commit is contained in:
Nick the Sick 2024-08-07 06:32:35 +02:00
parent 96601f7c99
commit 08593a279f
No known key found for this signature in database
GPG Key ID: F575992F156E5BCC
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/react": minor
---
Throw an error in development mode if immediatelyRender is not set in SSR mode

View File

@ -100,13 +100,12 @@ class EditorInstanceManager {
private getInitialEditor() {
if (this.options.current.immediatelyRender === undefined) {
if (isSSR || isNext) {
// TODO in the next major release, we should throw an error here
if (isDev) {
/**
* Throw an error in development, to make sure the developer is aware that tiptap cannot be SSR'd
* and that they need to set `immediatelyRender` to `false` to avoid hydration mismatches.
*/
console.warn(
throw new Error(
'Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.',
)
}