Flow Cookbook
Flow Cookbook: Flow & React
This recipe is part of the Flow Cookbook series. Flow and React are both Facebook projects - so as you might imagine, they work quite well together. React components can take type parameters to specify types for props and state. Type-checking works well with both functional and class components. Flow type annotations provide an alternative to propTypes runtime checks. Flow’s static checking has some advantages: Problems are reported immediately - it is not necessary to run tests that evaluate every component to identify props mismatches. Flow types can be more precise and concise than propTypes. Flow can also check state as well as props. In addition to checking that a component gets the correct props, Flow checks that props and states are used correctly within the component’s render method, and in other component methods. …
Flow Cookbook: Unpacking JSON API data
A case study on using runtime validators to match incoming API data to Flow types
Flow Cookbook
Type-checking can be a useful asset in a Javascript project. A type checker can catch problems that are introduced when adding features or refactoring, which can reduce the amount of time spent debugging and testing. Type annotations provide a form of always-up-to-date documentation that makes it easier for developers to understand an unfamiliar code base. But it is important to use type-checking effectively to get its full benefit. The Javascript community is fortunate to have a choice of two great type checkers. These recipes focus on Flow, and introduce patterns for using Flow effectively. …