mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-30 10:29:48 +02:00
fix: text not rendered on server-side rendering (#4796)
This commit is contained in:
5
.changeset/orange-zoos-exercise.md
Normal file
5
.changeset/orange-zoos-exercise.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix text not rendered on server-side rendering
|
@@ -1,7 +1,8 @@
|
|||||||
import React, { useRef, useLayoutEffect } from 'react'
|
import React, { useRef } from 'react'
|
||||||
import { Editor, Text, Path, Element, Node } from 'slate'
|
import { Editor, Text, Path, Element, Node } from 'slate'
|
||||||
|
|
||||||
import { ReactEditor, useSlateStatic } from '..'
|
import { ReactEditor, useSlateStatic } from '..'
|
||||||
|
import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leaf content strings.
|
* Leaf content strings.
|
||||||
@@ -69,7 +70,7 @@ const TextString = (props: { text: string; isTrailing?: boolean }) => {
|
|||||||
// eg makes native spellcheck opt out from checking the text node.
|
// eg makes native spellcheck opt out from checking the text node.
|
||||||
|
|
||||||
// useLayoutEffect: updating our span before browser paint
|
// useLayoutEffect: updating our span before browser paint
|
||||||
useLayoutEffect(() => {
|
useIsomorphicLayoutEffect(() => {
|
||||||
// null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
|
// null coalescing text to make sure we're not outputing "null" as a string in the extreme case it is nullish at runtime
|
||||||
const textWithTrailing = `${text ?? ''}${isTrailing ? '\n' : ''}`
|
const textWithTrailing = `${text ?? ''}${isTrailing ? '\n' : ''}`
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user