mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-12 10:14:02 +02:00
Fix performance issue with renderPlaceholder (#5339)
This commit is contained in:
5
.changeset/small-timers-sin.md
Normal file
5
.changeset/small-timers-sin.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixes #5335. To prevent performance issues, make sure to wrap custom `renderPlaceholder` values in `useCallback`.
|
@@ -129,6 +129,10 @@ export type EditableProps = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export const Editable = (props: EditableProps) => {
|
export const Editable = (props: EditableProps) => {
|
||||||
|
const defaultRenderPlaceholder = useCallback(
|
||||||
|
(props: RenderPlaceholderProps) => <DefaultPlaceholder {...props} />,
|
||||||
|
[]
|
||||||
|
)
|
||||||
const {
|
const {
|
||||||
autoFocus,
|
autoFocus,
|
||||||
decorate = defaultDecorate,
|
decorate = defaultDecorate,
|
||||||
@@ -137,7 +141,7 @@ export const Editable = (props: EditableProps) => {
|
|||||||
readOnly = false,
|
readOnly = false,
|
||||||
renderElement,
|
renderElement,
|
||||||
renderLeaf,
|
renderLeaf,
|
||||||
renderPlaceholder = props => <DefaultPlaceholder {...props} />,
|
renderPlaceholder = defaultRenderPlaceholder,
|
||||||
scrollSelectionIntoView = defaultScrollSelectionIntoView,
|
scrollSelectionIntoView = defaultScrollSelectionIntoView,
|
||||||
style: userStyle = {},
|
style: userStyle = {},
|
||||||
as: Component = 'div',
|
as: Component = 'div',
|
||||||
|
Reference in New Issue
Block a user