Search code examples
reactjsfluxflowtype

How to setup React+Flux with Flowtype


I've found it difficult to setup project that uses React+Flux and Flowtype.

Here is what my .flowconfig has:

[ignore]
.*/node_modules/.*
static/.*

[options]
module.name_mapper='^core/\(.*\)' -> '<PROJECT_ROOT>/core/\1'

and here is some file

/* @flow */
import Dispatcher from 'flux';
import Action from 'core/Action';

const AppDispatcher: Dispatcher<Action> = new Dispatcher();

export default AppDispatcher;

But when I try to run flow check I'm receiving:

core/Dispatcher.js:2
  2: import Dispatcher from 'flux';
                            ^^^^^^ flux. Required module not found

Can anyone share their successful experience in setting up the project?

Thanks.


Solution

  • This happens because you chose to ignore node_modules, so flow doesn't see flux. You need to remove this line from config or add declarations for flux