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.

Not working with react-native

See original GitHub issue

I created a boilerplate react-native project with react-native init. Then I modified the following files:

.babelrc

{
  "presets": ["react-native"],
  "plugins": [["flow-react-proptypes", { "ignoreNodeModules": true }]]
}

package.json

{
  "name": "test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "prop-types": "15.6.0",
    "react": "16.0.0",
    "react-native": "0.51.0"
  },
  "devDependencies": {
    "babel-jest": "21.2.0",
    "babel-plugin-flow-react-proptypes": "11.0.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "21.2.1",
    "react-test-renderer": "16.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

App.js

// @flow

import React, { Component } from "react"
import { View } from "react-native"

type Props = { test: string }

export default class App extends Component<Props> {
  render() {
    return <View />
  }
}

However, this does not generate the propTypes:

var App = _wrapComponent("App")(function (_Component) {
  _inherits(App, _Component);

  function App() {
    _classCallCheck(this, App);

    return _possibleConstructorReturn(this, (App.__proto__ || Object.getPrototypeOf(App)).apply(this, arguments));
  }

  _createClass(App, [{
    key: "render",
    value: function render() {
      return _react3.default.createElement(_reactNative.View, {
        __source: {
          fileName: _jsxFileName,
          lineNumber: 10
        }
      });
    }
  }]);

  return App;
}(_react2.Component));

exports.default = App;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
danilobuergercommented, Dec 15, 2017

Awesome. Thank you @brigand !

I updated the test repos, it works there and also triggers a propType warning in the UI, as test: string is missing from App.

Also tested in a real rn project, works there as well.

For anyone else finding this, if you use react-native, your babelrc should be:

{
  "presets": ["react-native"],
  "plugins": [["flow-react-proptypes", { "ignoreNodeModules": true, "useStatic": true }]]
}
0reactions
terrebcommented, Jul 3, 2019

It seems the issue is back. I’m testing with RN 0.57.8 and it doesn’t generate propTypes. I prepared the repo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - React Native
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here,...
Read more >
my app js not working in react native. what my mistake?
I newbie for react native. when I learning to hello world in app.js. when I run for android "native-react run-android" build success but...
Read more >
5 Most Common React Native Issues That Starters Face
Below Are Some React Native Issues that starters face · 1. App Registry Error in React Native: · 2. Development Server Error in...
Read more >
Troubleshooting | React Navigation
Troubleshooting. This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation.
Read more >
Troubleshooting for React Native | Sentry Documentation
Troubleshoot and resolve common issues with the React Native SDK.
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