Pārlūkot izejas kodu

docs: Remove uppy.use() call from render() method in DashboardModal example.

Renée Kooi 7 gadi atpakaļ
vecāks
revīzija
3a1db69813
1 mainītis faili ar 13 papildinājumiem un 3 dzēšanām
  1. 13 3
      website/src/docs/react-dashboard.md

+ 13 - 3
website/src/docs/react-dashboard.md

@@ -13,7 +13,19 @@ On top of all the [Dashboard][] options, the `<DashboardModal />` plugin adds tw
 
  - `open` - Boolean true or false, setting this to `true` opens the modal and setting it to `false` closes it.
  - `onRequestClose` - Callback called when the user attempts to close the modal, either by clicking the close button or by clicking outside the modal (if the `closeModalOnClickOutside` prop is set).
- - `plugins` - Array of plugins you need to use in Dashboard. Example: `plugins={['Webcam']}`.
+
+To use other plugins like [Webcam][] with the `<DashboardModal />` component, add them to the Uppy instance and then specify their `id` in the [`plugins`](/docs/dashboard/#plugins) prop:
+
+```js
+// Do this wherever you initialize Uppy, eg. in a React component's constructor method.
+// Do NOT do it in `render()` or any other method that is called more than once!
+uppy.use(Webcam) // `id` defaults to "Webcam"
+uppy.use(Webcam, { id: 'MyWebcam' }) // `id` is… "MyWebcam"
+```
+
+Then do `plugins={['Webcam']}`.
+
+A full example that uses a button to open the modal is shown below:
 
 ```js
 class MusicUploadButton extends React.Component {
@@ -41,8 +53,6 @@ class MusicUploadButton extends React.Component {
   }
 
   render () {
-    this.props.uppy.use(Webcam); // the same as this.props.uppy.use(Webcam, { id: "Webcam" });
-
     return (
       <div>
         <button onClick={this.handleOpen}>Upload some music</button>