React-native: Can't find variable:Symbol

Created on 19 Apr 2018  Â·  5Comments  Â·  Source: facebook/react-native

Environment

Environment:
OS: macOS High Sierra 10.13.4
Node: 9.11.0
Yarn: 1.5.1
npm: 5.8.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Steps to Reproduce

1、Create a new RN project with WebStorm
2、Define a Symbol in App.js
3、Select the Android platform to run
4、Code
type Props = {}; const Test = Symbol('test'); export default class App extends Component<Props> { render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Welcome to React Native! </Text> <Text style={styles.instructions}> To get started, edit App.js </Text> <Text style={styles.instructions}> {instructions} </Text> </View> ); } }

Actual Behavior

1、The following problems arise
screenshot_20180419-091248_hiasst

2、When selecting the "Debug JS Remotely" menu, the code works normally.

3、The code works well on the iOS platform。

Locked

Most helpful comment

es6-symbol unfortunately isn't working in my project. Importing it results in a Objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner, _store}). If you meant to render a collection of children, use an array instead error. Same with babel-polyfill.

Is Symbol support in the Android runtime on the roadmap? That's the broader issue here, and the fact that a workaround (sometimes) exists doesn't mean this isn't an implementation gap.

All 5 comments

@bingfeng1225

import 'es6-symbol/implement'

https://github.com/medikoo/es6-symbol

@isnifer
Thanks for your help

es6-symbol unfortunately isn't working in my project. Importing it results in a Objects are not valid as a React child (found: object with keys {$$typeof, type, key, ref, props, _owner, _store}). If you meant to render a collection of children, use an array instead error. Same with babel-polyfill.

Is Symbol support in the Android runtime on the roadmap? That's the broader issue here, and the fact that a workaround (sometimes) exists doesn't mean this isn't an implementation gap.

@Zacqary did you come up with a solution? I'm having the exact same issue.

I import babel-polyfill instead of es6-symbol and it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

phongyewtong picture phongyewtong  Â·  3Comments

DreySkee picture DreySkee  Â·  3Comments

jlongster picture jlongster  Â·  3Comments

ghost picture ghost  Â·  3Comments

aniss picture aniss  Â·  3Comments