Not working with react-native
See original GitHub issueI 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:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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:
It seems the issue is back. I’m testing with RN 0.57.8 and it doesn’t generate propTypes. I prepared the repo.