I wanted to test flow in my React Native project. I ran flow and found that it had no effect on Android files. I found the below given code in .flowconfig:
[ignore]
# We fork some components by platform.
.*/*.web.js
.*/*.android.js
Why did the React Native team ignore these files? I was not able find much information about the same else where. I know that I can make edits and flow would start considering android files as well, but I am not sure if it'd be right. For example, this is what fabergua has commented on a issue Flow doesn't recognize platform-specific react-native files related to it:
@mhollweck : React Native's default .flowconfig is set up to ignore all .android.js files. You can work around this by changing -./[.]android.js to ./node_modules/./*[.]android.js in the .flowconfig of your project.
But, should we go ahead with such workaround? Wouldn't it mess with the project when we upgrade it via react-native-git-upgrade?
I've always thought that they ignore Android by default because oftentimes you would prefer Flow to consistently operate on a particular platform's modules, and iOS was the original platform for React Native. Say you try to "jump to definition" for a particular function defined in both myFunction.ios.js
and myFunction.android.js
. With *.android.js
ignored, Flow will consistently jump you to the *.ios.js
files. So if your app is primarily focused on Android, I'd switch that ignore to *.ios.js
.
*.android.js
files are ignored by default to choose a platform arbitrarily, but there is also need to run flow in the following way:
[ignore]
; We fork some components by platform
.*/*[.]ios.js
...
[options]
module.file_ext=.native.js
module.file_ext=.android.js
module.file_ext=.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With