@@ -109,16 +109,20 @@ npm i -D @types/react @types/react-dom @types/react-redux
109109#### ` React.FunctionComponent<P> ` or ` React.FC<P> `
110110Type representing a functional component
111111``` tsx
112- const MyComponent: React .FC <MyComponentProps > = ...
112+ const MyComponent: React .FC <Props > = ...
113113```
114- [ ⇧ back to top] ( #table-of-contents )
115114
116115#### ` React.Component<P, S> `
117116Type representing a class component
118117``` tsx
119- class MyComponent extends React .Component <MyComponentProps , State > { ...
118+ class MyComponent extends React .Component <Props , State > { ...
119+ ` ` `
120+
121+ #### ` React .ComponentProps < typeof Component >
122+ Gets component Props type . You don ' t no need to export Props from your component ever!
123+ ` ` ` tsx
124+ type MyComponentProps = React.ComponentProps<typeof MyComponent>;
120125` ` `
121- [⇧ back to top](#table-of-contents)
122126
123127#### ` React.ComponentType<P> `
124128Type representing union type of (FC | Component )
@@ -127,30 +131,26 @@ const withState = <P extends WrappedComponentProps>(
127131 WrappedComponent: React.ComponentType<P>,
128132) => { ...
129133` ` `
130- [⇧ back to top](#table-of-contents)
131134
132135#### ` React.ReactElement<P> ` or ` JSX.Element `
133136Type representing a concept of React Element - representation of a native DOM component (e.g. ` <div /> ` ), or a user - defined composite component (e.g. ` <MyComponent /> ` )
134137` ` ` tsx
135138const elementOnly: React.ReactElement = <div /> || <MyComponent />;
136139` ` `
137- [⇧ back to top](#table-of-contents)
138140
139141#### ` React.ReactNode `
140142Type representing any possible type of React node (basically ReactElement (including Fragments and Portals ) + primitive JS types)
141143` ` ` tsx
142144const elementOrPrimitive: React.ReactNode = 'string' || 0 || false || null || undefined || <div /> || <MyComponent />;
143145const Component = ({ children: React.ReactNode }) => ...
144146` ` `
145- [⇧ back to top](#table-of-contents)
146147
147148#### ` React.CSSProperties `
148149Type representing style object in JSX (usefull for css -in -js styles )
149150` ` ` tsx
150151const styles: React.CSSProperties = { flexDirection: 'row', ...
151152const element = <div style={styles} ...
152153` ` `
153- [⇧ back to top](#table-of-contents)
154154
155155#### ` React.ReactEventHandler<E> `
156156Type representing generic event handler
@@ -159,7 +159,6 @@ const handleChange: React.ReactEventHandler<HTMLInputElement> = (ev) => { ... }
159159
160160<input onChange={handleChange} ... />
161161` ` `
162- [⇧ back to top](#table-of-contents)
163162
164163#### ` React.MouseEvent<E> ` | ` React.KeyboardEvent<E> ` | ` React.TouchEvent<E> ` etc ...
165164Type representing more specific event handler
@@ -168,6 +167,7 @@ const handleChange = (ev: React.MouseEvent<HTMLDivElement>) => { ... }
168167
169168<div onMouseMove={handleChange} ... />
170169` ` `
170+
171171[⇧ back to top ](#table -of -contents )
172172
173173-- -
0 commit comments