I don't know if this is a bug, maybe it's a flow issue or something I didn't know.
I try to import draft-js and benefit from it flow capabilities but I noticed that it doesn't work.
Is this normal?
import { Editor } from 'draft-js'
This does not work.
import { Editor } from 'draft-js/lib/Draft.js.flow'
This does not work neither.
import Editor from 'draft-js/lib/DraftEditor.react'
This works. autocompletion, validation, everything ok.
Using:
draft.js v0.10
flow v0.38
I using flow-typed, too. There is no draft-js generated stub which could override the draft-js module, so this is good.
Hi @aight8! It sounds like the problem is related to your JS build system resolving the path to the 'draft-js' project. In order to help you I'd like a bit more info.
First - are you using webpack or something else to build your JS? What configurations do you have set? What is your directory structure like?
If you are using webpack then please try this documentation to determine how it's resolving the path.
It makes sense to me that import Editor from 'draft-js/lib/DraftEditor.react' works - that statement tells your build system exactly where to find DraftEditor file. Similarly you should be able to use import Editor from 'draft-js/lib/Draft.react' and import Editor from 'draft-js/lib/Draft.react.flow'. I'm not sure why requiring the 'flow' extension doesn't work.
It also may help to look at the 'tex' example, which has a build system configured. https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/tex/server.js
Hope this is helpful and I look forward to talking through this issue more.
@flarnie I had same problem and finally I found that lib/Draft.js.flow in npm package does not have @flow. When I added @flow to the file, everything goes ok. Hope this is helpful 馃槃
Edit: And lib/DraftEditor.react.js.flow has @flow. This is why import Editor from 'draft-js/lib/DraftEditor.react' works, I guess.
Most helpful comment
@flarnie I had same problem and finally I found that
lib/Draft.js.flowin npm package does not have@flow. When I added@flowto the file, everything goes ok. Hope this is helpful 馃槃Edit: And
lib/DraftEditor.react.js.flowhas@flow. This is whyimport Editor from 'draft-js/lib/DraftEditor.react'works, I guess.