Skip to content

Commit 54b4063

Browse files
committed
Switch from JSX.Element to React.JSX.Element
The global JSX namespace has been deprecated for around two and a half years now in favor of using React.JSX, and as of the type declarations for React 19, it's been fully removed. By switching to the new namespace, this package maintains compatibility with React 19.
1 parent eae2474 commit 54b4063

File tree

9 files changed

+36
-31
lines changed

9 files changed

+36
-31
lines changed

.changeset/bright-turtles-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'slate-react': patch
3+
---
4+
5+
Update TypeScript declarations for React v19 by switching from JSX.Element to React.JSX.Element

docs/libraries/slate-react/editable.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Editable component
22

3-
## `Editable(props: EditableProps): JSX.Element`
3+
## `Editable(props: EditableProps): React.JSX.Element`
44

55
The `Editable` component is the main editing component. Note that it must be inside a `Slate` component.
66

@@ -16,9 +16,9 @@ type EditableProps = {
1616
readOnly?: boolean
1717
role?: string
1818
style?: React.CSSProperties
19-
renderElement?: (props: RenderElementProps) => JSX.Element
20-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
21-
renderPlaceholder?: (props: RenderPlaceholderProps) => JSX.Element
19+
renderElement?: (props: RenderElementProps) => React.JSX.Element
20+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
21+
renderPlaceholder?: (props: RenderPlaceholderProps) => React.JSX.Element
2222
scrollSelectionIntoView?: (editor: ReactEditor, domRange: DOMRange) => void
2323
as?: React.ElementType
2424
disableDefaultStyles?: boolean
@@ -39,7 +39,7 @@ If this prop is omitted or set to false, the editor remains in the default "edit
3939
4040
This prop is particularly useful when you want to display text or rich media content without allowing users to edit it, such as when displaying published content or a preview of the user's input.
4141
42-
#### `renderElement?: (props: RenderElementProps) => JSX.Element`
42+
#### `renderElement?: (props: RenderElementProps) => React.JSX.Element`
4343
4444
The `renderElement` prop is a function used to render a custom component for a specific type of Element node in the Slate.js document model.
4545
@@ -108,7 +108,7 @@ const DefaultElement = props => {
108108
}
109109
```
110110

111-
#### `renderLeaf?: (props: RenderLeafProps) => JSX.Element`
111+
#### `renderLeaf?: (props: RenderLeafProps) => React.JSX.Element`
112112

113113
The `renderLeaf` prop allows you to customize the rendering of leaf nodes in the document tree of your Slate editor. A "leaf" in Slate is the smallest chunk of text and its associated formatting attributes.
114114

@@ -151,7 +151,7 @@ Example usage:
151151
/>
152152
```
153153

154-
#### `renderText?: (props: RenderTextProps) => JSX.Element`
154+
#### `renderText?: (props: RenderTextProps) => React.JSX.Element`
155155

156156
The `renderText` prop allows you to customize the rendering of the container element for a Text node in the Slate editor. This is useful when you need to wrap the entire text node content or add elements associated with the text node as a whole, regardless of how decorations might split the text into multiple leaves.
157157

@@ -183,7 +183,7 @@ Example usage:
183183
/>
184184
```
185185

186-
#### `renderPlaceholder?: (props: RenderPlaceholderProps) => JSX.Element`
186+
#### `renderPlaceholder?: (props: RenderPlaceholderProps) => React.JSX.Element`
187187

188188
The `renderPlaceholder` prop allows you to customize how the placeholder of the Slate.js `Editable` component is rendered when the editor is empty. The placeholder will only be shown when the editor's content is empty.
189189

docs/libraries/slate-react/slate.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Slate Component
22

3-
## `Slate(props: SlateProps): JSX.Element`
3+
## `Slate(props: SlateProps): React.JSX.Element`
44

55
The `Slate` component must include somewhere in its `children` the `Editable` component.
66

packages/slate-react/src/components/chunk-tree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const defaultRenderChunk = ({ children }: RenderChunkProps) => children
1313
const ChunkAncestor = <C extends TChunkAncestor>(props: {
1414
root: TChunkTree
1515
ancestor: C
16-
renderElement: (node: Element, index: number, key: Key) => JSX.Element
17-
renderChunk?: (props: RenderChunkProps) => JSX.Element
16+
renderElement: (node: Element, index: number, key: Key) => React.JSX.Element
17+
renderChunk?: (props: RenderChunkProps) => React.JSX.Element
1818
}) => {
1919
const {
2020
root,

packages/slate-react/src/components/editable.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ export type EditableProps = {
158158
readOnly?: boolean
159159
role?: string
160160
style?: React.CSSProperties
161-
renderElement?: (props: RenderElementProps) => JSX.Element
162-
renderChunk?: (props: RenderChunkProps) => JSX.Element
163-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
164-
renderText?: (props: RenderTextProps) => JSX.Element
165-
renderPlaceholder?: (props: RenderPlaceholderProps) => JSX.Element
161+
renderElement?: (props: RenderElementProps) => React.JSX.Element
162+
renderChunk?: (props: RenderChunkProps) => React.JSX.Element
163+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
164+
renderText?: (props: RenderTextProps) => React.JSX.Element
165+
renderPlaceholder?: (props: RenderPlaceholderProps) => React.JSX.Element
166166
scrollSelectionIntoView?: (editor: ReactEditor, domRange: DOMRange) => void
167167
as?: React.ElementType
168168
disableDefaultStyles?: boolean

packages/slate-react/src/components/element.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ const defaultRenderElement = (props: RenderElementProps) => (
3434
const Element = (props: {
3535
decorations: DecoratedRange[]
3636
element: SlateElement
37-
renderElement?: (props: RenderElementProps) => JSX.Element
38-
renderChunk?: (props: RenderChunkProps) => JSX.Element
39-
renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element
40-
renderText?: (props: RenderTextProps) => JSX.Element
41-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
37+
renderElement?: (props: RenderElementProps) => React.JSX.Element
38+
renderChunk?: (props: RenderChunkProps) => React.JSX.Element
39+
renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element
40+
renderText?: (props: RenderTextProps) => React.JSX.Element
41+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
4242
}) => {
4343
const {
4444
decorations: parentDecorations,

packages/slate-react/src/components/leaf.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ const Leaf = (props: {
4848
isLast: boolean
4949
leaf: Text
5050
parent: Element
51-
renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element
52-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
51+
renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element
52+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
5353
text: Text
5454
leafPosition?: LeafPosition
5555
}) => {

packages/slate-react/src/components/text.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const Text = (props: {
2525
decorations: DecoratedRange[]
2626
isLast: boolean
2727
parent: Element
28-
renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element
29-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
30-
renderText?: (props: RenderTextProps) => JSX.Element
28+
renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element
29+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
30+
renderText?: (props: RenderTextProps) => React.JSX.Element
3131
text: SlateText
3232
}) => {
3333
const {

packages/slate-react/src/hooks/use-children.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import { ElementContext } from './use-element'
3030
const useChildren = (props: {
3131
decorations: DecoratedRange[]
3232
node: Ancestor
33-
renderElement?: (props: RenderElementProps) => JSX.Element
34-
renderChunk?: (props: RenderChunkProps) => JSX.Element
35-
renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element
36-
renderText?: (props: RenderTextProps) => JSX.Element
37-
renderLeaf?: (props: RenderLeafProps) => JSX.Element
33+
renderElement?: (props: RenderElementProps) => React.JSX.Element
34+
renderChunk?: (props: RenderChunkProps) => React.JSX.Element
35+
renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element
36+
renderText?: (props: RenderTextProps) => React.JSX.Element
37+
renderLeaf?: (props: RenderLeafProps) => React.JSX.Element
3838
}) => {
3939
const {
4040
decorations,

0 commit comments

Comments
 (0)