Some users might want to type their components with flow
.
To create a flow
-typed component, just use Reacli with either the --flow
or the -f
option:
reacli component ./my-super-component -f
It will generate a structure like this:
.
└── my-super-component
├── components
| ├── MySuperComponent.jsx
| ├── MySuperComponent.css
| └── MySuperComponentContainer.jsx
└── index.js
// @flow
annotation to configure the component to be flow
-typedProps
and State
types, in which we will type our component props or type.Component
class.defaultProps
in which we will be able to add some values to the component props that are not required.// @flow
annotation to configure the component to be flow
-typedProps
type to contain one optional prop called value1
of type string
Props
typedefaultProps
to configure the default values for the props that are not required (an empty string for the value1
prop)