question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Flow errors when using react-create-app

See original GitHub issue

Version

1.0.10

Guys love styled-components so thanks! Am on v1.0.10 and still getting flow-type errors. Note I am using create-react-app.

My flow config is as per create-react-app guidelines:

[ignore]
<PROJECT_ROOT>/node_modules/fbjs/.*

Mu deps:

"devDependencies": {
    "babel-eslint": "6.1.2",
    "eslint": "3.5.0",
    "eslint-plugin-flowtype": "2.18.1",
    "eslint-plugin-import": "1.12.0",
    "eslint-plugin-jsx-a11y": "2.2.2",
    "eslint-plugin-react": "5.2.2",
    "flow-bin": "^0.34.0",
    "react-scripts": "0.7.0"
  },
  "dependencies": {
    "react": "^15.3.2",
    "react-dom": "^15.3.2",
    "recompose": "^0.20.2",
    "styled-components": "^1.0.10"
  }

Here are the errors:

node_modules/styled-components/src/models/InlineStyle.js:3
  3: import camelizeStyleName from 'fbjs/lib/camelizeStyleName'
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fbjs/lib/camelizeStyleName. Required module not found

node_modules/styled-components/src/models/InlineStyle.js:5
  5: import { StyleSheet } from 'react-native'
                                ^^^^^^^^^^^^^^ react-native. Required module not found

node_modules/styled-components/src/native/index.js:4
  4: import reactNative from 'react-native'
                             ^^^^^^^^^^^^^^ react-native. Required module not found

node_modules/styled-components/src/utils/flatten.js:2
  2: import hyphenate from 'fbjs/lib/hyphenateStyleName'
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fbjs/lib/hyphenateStyleName. Required module not found

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
msmfsdcommented, Nov 22, 2016

OK this was not a create-react-app specific issue. I just followed the flow-support docs as recommended by @ryyppy - thanks all 👍

1reaction
ryyppycommented, Nov 21, 2016

You need to ignore the styled-components/src directory, as stated in our flow-support docs…

Add following ignore rule in your .flowconfig:

[ignore]
# We vendor our src directory, which is not needed for type-checking
.*/styled-components/src/.*

@mxstbr Is there a reason why styled-components needs to deliver the src content in the npm package?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow Flow build-time type checking #5995 - GitHub
You can run flow CLI to check for errors as a separate step, just like you do with jest tests. Most editors have...
Read more >
Error on type Props in react flow, converting create-react app ...
Flow syntax is not real JS. so things like type Props will fall apart when transpiling or bundling. You need to add a...
Read more >
Troubleshooting Guide - React Flow
This guide contains warnings and errors that can occur when using React Flow. We are also adding common questions and pitfalls that we...
Read more >
Create React App | Flow
Learn how to use Flow with Create React App. ... All you need to do is install Flow and create a .flowconfig file...
Read more >
Static Type Checking - React
Static type checkers like Flow and TypeScript identify certain types of problems before you even run your code. They can also improve developer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found