Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup react native to use flow?

I was wondering how I have to setup .flowConfig in order to use flow on a React- Native project. I created an empty .flowConfig file but as soon as I include the react-native module in a JS source file and check this file with flow, flow displays a 'not_found' error message.

like image 718
rogergl Avatar asked Apr 09 '15 17:04

rogergl


People also ask

How do you use flow in React Native?

Let's get started 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.

Should I use flow in React Native?

Flow will help you prevent bugs and allow for better code documentation among other things. A lot of the React Native documentation and source code already also uses flow, so there has never been a better time to start using it!

What is Flowconfig?

flowconfig file tells Flow to include the specified library definitions when type checking your code. Multiple libraries can be specified. By default, the flow-typed folder in your project root directory is included as a library directory.


2 Answers

Follow the instructions on https://flowtype.org/ to create your projects .flowconfig file, you can copy and paste it, you also have to install flow via brew install flow and add the flow binaries to your package.json, once you've done all this, you should be able to manually run flow and check for error types, but, that is not really optimal.

I haven't been able to set up flow on atom without using nuclide, I'm guessing with some digging around the packages you can find something that works that allows for on-the-fly flow checking.

The link provided by @jerome (https://egghead.io/lessons/react-setup-nuclide-to-use-flow-and-eslint-mac) is useful but only for nuclide installation, still worth a watch.

like image 130
Oscar Franco Avatar answered Oct 10 '22 04:10

Oscar Franco


I advise to watch https://egghead.io/lessons/react-setup-nuclide-to-use-flow-and-eslint-mac it explains how to use Flow with Nuclide. I had issue to make flow works and my main mistake was that I didn't install flow (brew install flow). On the official site (https://flowtype.org/docs/getting-started.html) they don't mention you need to install flow (or it is not super obvious if it is the case). Anyway watch the video it is great, it even explains ESLint :)

like image 40
Jerome Mouneyrac Avatar answered Oct 10 '22 03:10

Jerome Mouneyrac