You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Cookbook.md
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
*[How to use `ref`s in examples?](#how-to-use-refs-in-examples)
8
8
*[How to exclude some components from style guide?](#how-to-exclude-some-components-from-style-guide)
9
9
*[How to hide some components in style guide but make them available in examples?](#how-to-hide-some-components-in-style-guide-but-make-them-available-in-examples)
10
+
*[How to render React components that aren’t part of the style guide?](#how-to-render-react-components-that-arent-part-of-the-style-guide)
10
11
*[How to dynamically load other components in an example?](#how-to-dynamically-load-other-components-in-an-example)
11
12
*[How to display the source code of any file?](#how-to-display-the-source-code-of-any-file)
12
13
*[How to set global styles for user components?](#how-to-set-global-styles-for-user-components)
@@ -17,7 +18,7 @@
17
18
*[How to change style guide dev server logs output?](#how-to-change-style-guide-dev-server-logs-output)
18
19
*[How to debug my components and examples?](#how-to-debug-my-components-and-examples)
19
20
*[How to debug the exceptions thrown from my components?](#how-to-debug-the-exceptions-thrown-from-my-components)
20
-
*[How to use React's production or development build?](#how-to-use-reacts-production-or-development-build)
21
+
*[How to use production or development build of React?](#how-to-use-production-or-development-build-of-react)
21
22
*[Why does the style guide list one of my prop types as `unknown`?](#why-does-the-style-guide-list-one-of-my-prop-types-as-unknown)
22
23
*[Why object references don’t work in example component state?](#why-object-references-dont-work-in-example-component-state)
23
24
*[How to use Vagrant with Styleguidist?](#how-to-use-vagrant-with-styleguidist)
@@ -90,9 +91,18 @@ global.Button = Button
90
91
91
92
The `Button` component will be available in every example without a need to `require` it.
92
93
94
+
## How to render React components that aren’t part of the style guide?
## How to dynamically load other components in an example?
94
104
95
-
Although examples don't have direct access to webpack's `require.context` feature, you _can_ use it in a separate helper file which you require in your example code. If you wanted to create an example to load and show all of your icon components, you could do this:
105
+
Although examples don’t have direct access to webpack’s `require.context` feature, you _can_ use it in a separate helper file which you require in your example code. If you wanted to create an example to load and show all of your icon components, you could do this:
First, coode examples can receive [props and settings](Documenting.md#usage-examples-and-readme-files):
135
+
First, code examples can receive [props and settings](Documenting.md#usage-examples-and-readme-files):
126
136
127
137
```js { "file": "../mySourceCode.js" }
128
138
```
@@ -359,9 +369,9 @@ module.exports = {
359
369
2. Press the  button in your browser’s developer tools.
360
370
3. Press the  button and the debugger will stop execution at the next exception.
361
371
362
-
## How to use React's production or development build?
372
+
## How to use production or development build of React?
363
373
364
-
In some cases, you might need to use React's development build instead of the default [production one](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build). For example, this might be needed if you use React Native and make references to a React Native component's propTypes in your code. As React removes all propTypes in its production build, your code will fail. By default, React Styleguidist uses the development build for the dev server, and the production one for static builds.
374
+
In some cases, you might need to use development build of React instead of the default [production one](https://reactjs.org/docs/optimizing-performance.html#use-the-production-build). For example, this might be needed if you use React Native and make references to a React Native component's PropTypes in your code. As React removes all PropTypes in its production build, your code will fail. By default, React Styleguidist uses the development build for the dev server, and the production one for static builds.
365
375
366
376
```js
367
377
importReactfrom'react'
@@ -377,7 +387,7 @@ CustomInput.propTypes = {
377
387
378
388
If you use code similar to this, you might encounter errors such as `Cannot read property 'isRequired' of undefined`.
379
389
380
-
To avoid this, you need to tell React Styleguidist to use React's development build. To do this, simply set the `NODE_ENV` variable to `development` in your npm script.
390
+
To avoid this, you need to tell React Styleguidist to use React’s development build. To do this, simply set the `NODE_ENV` variable to `development` in your npm script.
0 commit comments