Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: In this environment the sources for assign MUST be an object. This error is a performance optimization and not spec compliant. #19009

Closed
3 tasks done
selabie68 opened this issue Apr 25, 2018 · 11 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@selabie68
Copy link

selabie68 commented Apr 25, 2018

Environment

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

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

simulator screen shot - iphone 6 - 2018-04-25 at 15 07 38

Steps to Reproduce

Happens on loading of app.

@fungilation
Copy link

fungilation commented May 4, 2018

I'm hitting the same, in multiple components on Android and only Android:

				<View
					style={[
						styles.stickyHeader,
						{
							width: viewWidth,
							...(stickyHeaderHeight ? { height: stickyHeaderHeight } : null),
						},
					]}
				>
...

(in my forked version of https://github.com/maxs15/react-native-modalbox/blob/master/index.js)

Redbox error:
screenshot 2018-05-03 22 46 43

By process of elimination, I tried taking out components that included the offending line that triggered the same In this environment the sources for assign MUST be an object... error. I take one component out, another component gives the same error. (above snippet is one sample of where error triggers)

Looking at https://github.com/facebook/react-native/blob/0.54-stable/Libraries/polyfills/Object.es6.js which throws this error. This error is thrown only when __DEV__ is true. So why bother? I breaks my app in dev and only in dev, when it should have allowed my app to continue executing. (hitting Dismiss on redbox ends with my app stalled on a white screen)

Can this error be changed to a console.warn instead of a redbox on __DEV__?

PS. in my app, iOS works fine and I support only iOS 9 and up. I just started testing on Android, and I keep hitting this error. I assume issue writer above is hitting this on iOS 8 or lower.

@react-native-bot
Copy link
Collaborator

react-native-bot commented May 14, 2018

Closing as the original issue has no description of the issue. Please open a new issue with more information.

@fungilation
Copy link

Hey stupid bot, there's plenty of description here including screenshots.

@blackflame007
Copy link

The bot is right, I had the exact same error message and I just fixed it. Your error message is just not telling you your error. I was working in an Expo react native project with the Animated library dealing with rotation. To rotate with degrees one must use a string ex '-120deg'. My error was I put '-120eg' on my strings. I'd say you are sending data as the wrong type in one of your files. @fungilation @selabie68

@J-S-Thomas
Copy link

Im having the same error following Scott Talinski (level up) tutorial called React Native For Everyone (video #12) cant figure out wtf is going on here. iOS and Android is bugging out. where the hell is View(at YellowBox.js:425)?

@maccomaccomaccomacco
Copy link

@fungilation I just noticed a particular in your code, similar to a particular in my code
you're trying to add an object property in this way:
...(stickyHeaderHeight ? { height: stickyHeaderHeight } : null),
but this should be

...(stickyHeaderHeight ? { height: stickyHeaderHeight } : {}),

As well as I was trying to use

...(caloriesInDay && { calories: caloriesArr.reduce((a,b)=>{return a+b},0)} )
but the right way is
...(caloriesInDay ? { calories: caloriesArr.reduce((a,b)=>{return a+b},0)} : {} )

@fungilation
Copy link

Interesting. I've since avoided the issue at init by always assigning a int to stickyHeaderHeight.

@skiral
Copy link

skiral commented Dec 2, 2018

I faced the same issue, the issue happens when you try to use spread operator on a non object|array
...(NON_OBJECT_OR_ARRAY) will fail
I am experiencing it in JSX.

@jasperkuperus
Copy link

jasperkuperus commented Dec 11, 2018

For me, the error happened when passing something different than an Object to a prop that has a proptype of Object:

<Menu
  scrollViewProps={hasProps && {
    prop1: 'value',
  }}
/>

Simple solution:

<Menu
  scrollViewProps={(hasProps ? {
    prop1: 'value',
  }: {})}
/>

@ldgarcia
Copy link

In my case I incorrectly curried a function inside my component class:

  // Incorrect, with typo
  renderFoo = (x) = (y) => {}
 // Correct
 renderFoo = (x) => (y) => {}

@Sumit-Chakole
Copy link

I faced the same issue, the issue happens when you try to use spread operator on a non object|array
...(NON_OBJECT_OR_ARRAY) will fail
I am experiencing it in JSX.

This explaination is absolutely correct!

@facebook facebook locked as resolved and limited conversation to collaborators May 14, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

10 participants