-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Documentation: Adding
withInstanceId
HoC documentation
- Loading branch information
1 parent
ee8097b
commit 9d57a33
Showing
6 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Higher Order Components | ||
======================= | ||
|
||
This directory includes a library of generic Higher Order React Components. | ||
|
||
[Learn more abouth Higher Order Components](https://facebook.github.io/react/docs/higher-order-components.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import ReactMarkdown from 'react-markdown'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs } from '@storybook/addon-knobs'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import readme from '../README.md'; | ||
|
||
storiesOf( 'Higher Order Components', module ) | ||
.addDecorator( withKnobs ) | ||
.add( 'Intro', () => <ReactMarkdown source={ readme } /> ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
withInstanceId | ||
============== | ||
|
||
Some components need to generate a unique id for each instance. This could serve as suffixes to element ID's for example. | ||
Wrapping a component with `withInstanceId` provides a unique `instanceId` to serve this purpose. | ||
|
||
## Usage | ||
|
||
```jsx | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { withInstanceId } from 'components'; | ||
|
||
function MyCustomElement( { instanceId } ) { | ||
return ( | ||
<div id={ `my-custom-element-${ instanceId }` }> | ||
content | ||
</div> | ||
); | ||
} | ||
|
||
export default withInstanceId( MyCustomElement ); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import ReactMarkdown from 'react-markdown'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { withKnobs } from '@storybook/addon-knobs'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import readme from '../README.md'; | ||
|
||
storiesOf( 'Higher Order Components', module ) | ||
.addDecorator( withKnobs ) | ||
.add( 'withInstanceId', () => <ReactMarkdown source={ readme } /> ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters