facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.33k stars 24.23k forks source link

Object.is is undefined in Android #19139

Closed thevishnupradeep closed 6 years ago

thevishnupradeep commented 6 years ago

When I try to run my JS Code in Android I get error: E/ReactNativeJS: TypeError: undefined is not a function (evaluating 'Object.is(t.tasks,this.state.tasks)')

This error comes only in Android. It works perfectly in iOS

Environment

Environment: OS: macOS High Sierra 10.13.4 Node: 9.11.1 Yarn: 1.5.1 npm: 5.6.0 Watchman: 4.9.0 Xcode: Xcode 9.3 Build version 9E145 Android Studio: 3.1 AI-173.4720617

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

Steps to Reproduce

Use Object.is in code.

Expected Behavior

Should just compare given objects and return a boolean value.

Actual Behavior

Gets an undefined error.

react-native-bot commented 6 years ago

Thanks for posting this! It looks like your issue may be incomplete. Are all the fields required by the Issue Template filled out?

If you believe your issue contains all the relevant information, let us know in order to have a maintainer remove the No Template label. Thank you for your contributions.

How to ContributeWhat to Expect from Maintainers

thevishnupradeep commented 6 years ago

@react-native-bot The issue now contains all the relevant information

ghost commented 6 years ago

React native in android typically runs on older version of javascript engine than iOS so Object.is might not work by default as it's es6 feature. So, you just have to polyfill it with something like this

pierreneter commented 6 years ago

@bhandarijiwan but does react-native have babel? I still see it working normally with ES6 features.

ghost commented 6 years ago

@pierreneter It does but not everything in es6 is supported out of the box. Here is list of plugins in preset: react-native. Everything else you need supply a plugin/polyfill yourself.

hramos commented 6 years ago

Commented on the PR - people can use a Babel plugin as a workaround.