wip: Working on better developer docs
This commit is contained in:
parent
c16b212bb9
commit
e0a261731f
25 changed files with 461 additions and 152 deletions
|
@ -1,15 +1,48 @@
|
|||
---
|
||||
title: getRenderProps()
|
||||
title: Pattern.getRenderProps()
|
||||
---
|
||||
|
||||
A pattern's `getRenderProps()` method will return a set of properties
|
||||
that allow the pattern to be rendered be an external renderer such as
|
||||
a React component. It should only be called after calling `Pattern.draft()`.
|
||||
|
||||
## Pattern.getRenderProps() signature
|
||||
|
||||
```js
|
||||
Object pattern.getRenderProps()
|
||||
```
|
||||
|
||||
Returns the *props* that allow a pattern to be rendered as a React component.
|
||||
The object returned by this method contains the following properties:
|
||||
|
||||
| Property | Description |
|
||||
| --------:| ----------- |
|
||||
| `svg` | An [Svg Object](/reference/api/svg/) object with the `preRender` hook applied |
|
||||
| `width` | Widht of the drafted pattern in `mm` |
|
||||
| `height` | Height of the drafted pattern in `mm` |
|
||||
| `settings` | The settings used to draft the pattern |
|
||||
| `events` | An object with properties `debug`, `info`, `warning`, and `error` holding events of that type that were generated during the draft of the pattern |
|
||||
| `parts` | A plain object holding the drafted parts |
|
||||
|
||||
<Tip>
|
||||
|
||||
See [the Draft React component](/reference/packages/components/draft/) for details.
|
||||
See [the Draft React component](/reference/packages/components/draft/) for more info.
|
||||
|
||||
</Tip>
|
||||
|
||||
|
||||
## Pattern.getRenderProps() example
|
||||
|
||||
```jsx
|
||||
import React from 'react
|
||||
import Aaron from "@freesewing/aaron"
|
||||
import Draft from "@freesewing/components/Draft"
|
||||
|
||||
const MyReactComponent = ({ measurements }) => {
|
||||
const pattern = new Aaron({ measurements })
|
||||
|
||||
return <Draft {...pattern.draft().getRenderProps()} />
|
||||
}
|
||||
|
||||
export default MyReactComponent
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue