-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
Environment:
OS: macOS High Sierra 10.13
Node: 8.6.0
Yarn: 1.1.0
npm: 5.3.0
Watchman: 4.9.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.1 => 0.49.1
Target Platform: iOS (11)
Steps to Reproduce
- react-native init
- Add Switch component to App.js
- Run unit test
Expected Behavior
Should run unit test without console.error
Actual Behavior
console.error node_modules/fbjs/lib/warning.js:33
Warning: Stateless function components cannot be given refs. Attempts to access this ref will fail.
Check the render method of `Switch`.
in Unknown (created by Switch)
in Switch (created by App)
in View (created by View)
in View (created by App)
in App
Reproducible Demo
App.js
file
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import { View, Switch } from 'react-native';
export default class App extends Component<{}> {
render() {
return (
<View>
<Switch />
</View>
);
}
}
__tests__/App.test.js
file
import 'react-native';
import React from 'react';
import App from '../App';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
it('renders correctly', () => {
const tree = renderer.create(
<App />
);
});
package.json
file
{
"name": "test",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.0.0-beta.5",
"react-native": "0.49.2"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1",
"react-test-renderer": "16.0.0-beta.5"
},
"jest": {
"preset": "react-native"
}
}
raphKn, i-have-no-name, sam-vdp, kevinmeyvaert, markoudev and 2 more
Metadata
Metadata
Assignees
Labels
Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.