react-html-props
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "react-html-props", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"author": "Justin Mahar <contact@justinmahar.com>", | ||
@@ -5,0 +5,0 @@ "description": "Convenience TypeScript type definitions for all HTML element props.", |
@@ -45,2 +45,16 @@ <h2 align="center"> | ||
const MyComponent = (props: DivProps) => { | ||
return <div {...props}>My component</div>; | ||
}; | ||
``` | ||
### Unpacking Children | ||
We can use [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#object_destructuring) to unpack `children` from the rest of an element's props. | ||
Using `div` as an example again: | ||
```tsx | ||
import { DivProps } from "react-html-props"; | ||
export const MyComponent = ({ children, ...divProps }: DivProps): JSX.Element => { | ||
@@ -51,4 +65,2 @@ return <div {...divProps}>{children}</div>; | ||
Here we are using [object destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#object_destructuring) to unpack `children` from the rest of `div`'s props. | ||
### Mixing With Custom Props | ||
@@ -55,0 +67,0 @@ |
23469
218