Guest User

Untitled

a guest
Jul 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. Whenever I use
  2.  
  3. ```js
  4. MyComponent.defaultProps = {
  5. ...something
  6. }
  7. ```
  8. after MyComponent is created by
  9.  
  10.  
  11. ```js
  12. class MyComponent extends Component {
  13. ...
  14. }
  15.  
  16. ```
  17. flow gives the error:
  18.  
  19. ```
  20. object literal. This type is incompatible with undefined
  21. Did you forget to declare type parameter `DefaultProps` of identifier `Component`
  22. ```
  23.  
  24. This is type error. Flow has already inferred the type for your class before you try to mutate the defaultProps property.
  25.  
  26. And since you didn't give it a type it was inferred as void. This should fix it:
  27.  
  28. ```js
  29. class MyComponent extends Component {
  30. static defaultProps: Object;
  31. }
  32. ```
Add Comment
Please, Sign In to add comment