File tree Expand file tree Collapse file tree 1 file changed +0
-66
lines changed Expand file tree Collapse file tree 1 file changed +0
-66
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,6 @@ ReactDOM.render((
65
65
66
66
http://localhost:9001
67
67
68
- online example: http://react-component.github.io/trigger/
69
-
70
68
## Development
71
69
72
70
```
@@ -252,75 +250,11 @@ npm start
252
250
253
251
```
254
252
npm test
255
- npm run chrome-test
256
- ```
257
-
258
- ## Coverage
259
-
260
- ```
261
253
npm run coverage
262
254
```
263
255
264
256
open coverage/ dir
265
257
266
- ## React 16 Note
267
-
268
- After React 16, you won't access popup element's ref in parent component's componentDidMount, which means following code won't work.
269
-
270
- ``` javascript
271
- class App extends React .Component {
272
- componentDidMount () {
273
- this .input .focus (); // error, this.input is undefined.
274
- }
275
-
276
- render () {
277
- return (
278
- < Trigger
279
- action= {[' click' ]}
280
- popup= {< div>< input ref= {node => this .input = node} type= " text" / >< / div> }
281
- >
282
- < button> click< / button>
283
- < / Trigger>
284
- )
285
- }
286
- }
287
- ```
288
-
289
- Consider wrap your popup element to a separate component:
290
-
291
- ``` javascript
292
- class InputPopup extends React .Component {
293
- componentDidMount () {
294
- this .props .onMount ();
295
- }
296
-
297
- render () {
298
- return (
299
- < div>
300
- < input ref= {this .props .inputRef } type= " text" / >
301
- < / div>
302
- );
303
- }
304
- }
305
-
306
- class App extends React .Component {
307
- handlePopupMount () {
308
- this .input .focus (); // error, this.input is undefined.
309
- }
310
-
311
- render () {
312
- return (
313
- < Trigger
314
- action= {[' click' ]}
315
- popup= {< InputPopup inputRef= {node => this .input = node} onMount= {this .handlePopupMount } / > }
316
- >
317
- < button> click< / button>
318
- < / Trigger>
319
- )
320
- }
321
- }
322
- ```
323
-
324
258
## License
325
259
326
260
rc-trigger is released under the MIT license.
You can’t perform that action at this time.
0 commit comments