File tree 1 file changed +18
-5
lines changed
1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -271,21 +271,34 @@ Another way - compare "rendered" element type
271
271
272
272
``` js
273
273
const element = < Component / >
274
- console .log (element .type === ( < Component/ > ) .type ) // true
274
+ console .log (element .type === < Component / > .type ) // true
275
275
276
276
// better - precache rendered type
277
277
const element = < Component / >
278
- const ComponentType = ( < Component / > ) .type
279
- console .log (element .type === ComponentType // true
278
+ const ComponentType = < Component / > .type
279
+ console .log (element .type === ComponentType) // true
280
280
```
281
281
282
+ But you might have to provide all required props. See [ original issue] ( https://github.com/gaearon/react-hot-loader/issues/304 ) .
283
+ This is most reliable way to compare components, but it will not work with required props.
284
+
282
285
Another way - compare Component name.
283
- > Not all components has a name
286
+
287
+ > Not all components has a name. ** In production displayName could not exists.**
288
+
289
+ ``` js
290
+ const element = < Component / >
291
+ console .log (element .displayName === ' Component' ) // true
292
+ ```
293
+
294
+ For Components you might be able to use ** instanceof** operator
295
+
284
296
``` js
285
297
const element = < Component / >
286
- console .log (element .displayName === " Component" ) // true
298
+ console .log (element .type instanceof Component) // true
287
299
```
288
300
301
+ This is something we did not solve yet.
289
302
290
303
### Webpack ExtractTextPlugin
291
304
You can’t perform that action at this time.
0 commit comments