Skip to content

Commit f2c7af1

Browse files
Basarat Ali SyedBasarat Ali Syed
Basarat Ali Syed
authored and
Basarat Ali Syed
committed
react node closes #160
1 parent 39525df commit f2c7af1

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/jsx/tsx.md

+21
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@ class MyComponent extends React.Component<Props, {}> {
5555
<MyComponent foo="bar" />
5656
```
5757

58+
### JSX Tip : Interface for renderable
59+
60+
React can render a few things like `JSX` or `string`. There are all consolidated into the type `React.ReactNode` so use it for when you want to accept renderables e.g.
61+
62+
```ts
63+
interface Props {
64+
header: React.ReactNode;
65+
body: React.ReactNode;
66+
}
67+
class MyComponent extends React.Component<Props, {}> {
68+
render() {
69+
return <div>
70+
{header}
71+
{body}
72+
</div>;
73+
}
74+
}
75+
76+
<MyComponent foo="bar" />
77+
```
78+
5879
## Non React JSX
5980
TypeScript provides you with the ability to use something other than React with JSX in a type safe manner. The following lists the customizability points, but note that this is for advanced UI framework authors:
6081

0 commit comments

Comments
 (0)