eatdrinkhealthy / edh-app

The Eat Drink Healthy web (and tentatively mobile / cordova) app created with Meteor and React.
0 stars 0 forks source link

Flowtype question: passing < types > to react component (when?) #29

Open stevenjmarsh opened 7 years ago

stevenjmarsh commented 7 years ago

In what cases do you pass types to a react component, i.e.

class LocationsMap extends PureComponent<void, ILocationsMapProps, void> {
   ...
}

vs. just setting props in the class

class LocationsMap extends PureComponent {
   props: ILocationsMapProps;
   ...
}

also, go over an appropriate use example for defaultProps

see flow recipes here

stevenjmarsh commented 7 years ago

I tested both scenarios. both work. when? why?

type ILocationsMapProps = {
   ...
};

class LocationsMap extends PureComponent {
// OR
class LocationsMap extends PureComponent<any, ILocationsMapProps, any> {
   props: ILocationsMapProps;
   ...
}