Flow is a framework that, like TypeScript, promotes static typing in JavaScript. And like TypeScript it ships with React Native without any issues. So I was wondering, Why would they promote two ways of static typing?
It seems that Flow is less of a commitment than TypeScript since it uses regular .js
files instead of .ts
.
We start by initializing a new React Native project (without Expo) by running: npx react-native init flow
in our terminal where ‘flow’ is the name of the project. This can be any valid name you want.
Try and run the bare app on your device or emulator. I will be using a physical Android device and run it using npx react-native run-android
. Make sure you’re in the correct directory.
After running the bare app we will continue with the setup for Flow. We already have a .flowconfig
file, but we are missing the dependency.
Run npm i --save-dev flow-bin
to install Flow as a dev dependency.
Open your App.js
and you can already see the first Flow syntax. Your IDE might give you errors for it. I’m using WebStorm as it has built in support for Flow and it is free for students.
#javascript #react #react-native