Skip to content

Commit 252083f

Browse files
committed
Fixed #645 deprecated JSX.Element with React.JSX.Element
1 parent 2d61717 commit 252083f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/basic/getting-started/basic-type-examples.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Relevant for components that accept other React components as props.
8888
```tsx
8989
export declare interface AppProps {
9090
children?: React.ReactNode; // best, accepts everything React can render
91-
childrenElement: JSX.Element; // A single React element
91+
childrenElement: React.JSX.Element; // A single React element
9292
style?: React.CSSProperties; // to pass through style props
9393
onChange?: React.FormEventHandler<HTMLInputElement>; // form events! the generic parameter is the type of event.target
9494
// more info: https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_usecase/#wrappingmirroring
@@ -124,16 +124,16 @@ This is because `ReactNode` includes `ReactFragment` which allowed type `{}` bef
124124
</details>
125125

126126
<details>
127-
<summary><b>JSX.Element vs React.ReactNode?</b></summary>
127+
<summary><b>React.JSX.Element vs React.ReactNode?</b></summary>
128128

129-
Quote [@ferdaber](https://github.com/typescript-cheatsheets/react/issues/57): A more technical explanation is that a valid React node is not the same thing as what is returned by `React.createElement`. Regardless of what a component ends up rendering, `React.createElement` always returns an object, which is the `JSX.Element` interface, but `React.ReactNode` is the set of all possible return values of a component.
129+
Quote [@ferdaber](https://github.com/typescript-cheatsheets/react/issues/57): A more technical explanation is that a valid React node is not the same thing as what is returned by `React.createElement`. Regardless of what a component ends up rendering, `React.createElement` always returns an object, which is the `React.JSX.Element` interface, but `React.ReactNode` is the set of all possible return values of a component.
130130

131-
- `JSX.Element` -> Return value of `React.createElement`
131+
- `React.JSX.Element` -> Return value of `React.createElement`
132132
- `React.ReactNode` -> Return value of a component
133133

134134
</details>
135135

136-
[More discussion: Where ReactNode does not overlap with JSX.Element](https://github.com/typescript-cheatsheets/react/issues/129)
136+
[More discussion: Where ReactNode does not overlap with React.JSX.Element](https://github.com/typescript-cheatsheets/react/issues/129)
137137

138138
[Something to add? File an issue](https://github.com/typescript-cheatsheets/react/issues/new).
139139

docs/basic/getting-started/function-components.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type AppProps = {
1515
const App = ({ message }: AppProps) => <div>{message}</div>;
1616

1717
// you can choose annotate the return type so an error is raised if you accidentally return some other type
18-
const App = ({ message }: AppProps): JSX.Element => <div>{message}</div>;
18+
const App = ({ message }: AppProps): React.JSX.Element => <div>{message}</div>;
1919

2020
// you can also inline the type declaration; eliminates naming the prop types, but looks repetitive
2121
const App = ({ message }: { message: string }) => <div>{message}</div>;

0 commit comments

Comments
 (0)