@@ -12,17 +12,30 @@ React components dynamically based on the requested client-package.
1212
1313## Getting started
1414
15- ``` bash
15+ ``` sh
1616npm i react-component-catalog --save
17+
18+ # or
19+ yarn add react-component-catalog
1720```
1821
19- ## Basic Usage
22+ Then install the correct versions of each peerDependency package, which are
23+ listed by the command:
24+
25+ ``` sh
26+ npm info " react-component-catalog@latest" peerDependencies
27+ ```
28+
29+ If using npm 5+, use this shortcut:
30+
31+ ``` sh
32+ npx install-peerdeps --dev react-component-catalog
2033
21- ### Requirements
34+ # or
35+ yarn add react-component-catalog -D --peer
36+ ```
2237
23- As this package depends on [ ` react-hooks ` ] ( https://reactjs.org/docs/hooks-overview.html ) ,
24- ` "react": "^16.8.0" ` and ` "react-dom": "^16.8.0" ` are required (see
25- ` peerDependencies ` in [ package.json] ( ./package.json ) ).
38+ ## Basic Usage
2639
2740### First register the components
2841
@@ -134,6 +147,39 @@ const App = () => {
134147export default App
135148```
136149
150+ ### Use catalog with ` ref `
151+
152+ > Refs provide a way to access DOM nodes or React elements created in the render
153+ method. ([ Source: reactjs.org] ( https://reactjs.org/docs/refs-and-the-dom.html ) )
154+
155+ It is possible to use ` react-component-catalog ` with ` ref ` as well. It would
156+ look similar to (works also with ` <CatalogComponent /> ` ):
157+
158+ ``` js
159+ const TestComponent = withCatalog (props => (
160+ < button {... props} type= " button" >
161+ Hello Button
162+ < / button>
163+ ))
164+
165+ /* eslint-disable react/no-multi-comp */
166+ class App extends React .Component {
167+ constructor (props ) {
168+ super (props)
169+ this .setRef = React .createRef ()
170+ }
171+
172+ render () {
173+ // or <CatalogComponent component="TestComponent" ref={this.setRef} />
174+ return (
175+ < CatalogProvider catalog= {new Catalog ({ components: { TestComponent } })}>
176+ < TestComponent ref= {this .setRef } / >
177+ < / CatalogProvider>
178+ )
179+ }
180+ }
181+ ```
182+
137183## How to build and test this package
138184
139185``` sh
0 commit comments