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

Cannot read property 'changedBits' of undefined #12645

Closed
danielkcz opened this issue Apr 18, 2018 · 6 comments
Closed

Cannot read property 'changedBits' of undefined #12645

danielkcz opened this issue Apr 18, 2018 · 6 comments

Comments

@danielkcz
Copy link

danielkcz commented Apr 18, 2018

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Using the new Context API in React Native app ends up with an exception.

image

Unfortunately, I am unable to provide viable reproduction environment. I tried the CodeSandbox and Snack Expo and both are working just fine. This is happening in my React Native app running on my Android phone. Only thing I've got is this screenshot from the debugger.

image

Strangely enough if that code on line 8439 would read providerFiber.type._context then it would have been working correctly. Any chance there is a typo? :)

export const rootContext = React.createContext<TRootModel>()
export const RootProvider = rootContext.Provider

export const App = () => (
  <RootProvider value={RootModel.create()}>
    <Text>OK</Text>
  </RootProvider>
)

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

  • react: 16.3.2
  • react-native: 0.54.2
  • Windows 10 x64
@aweary
Copy link
Contributor

aweary commented Apr 18, 2018

Thanks for the report @FredyC . changedBits was renamed to _changedBits in #12358. I'm not too familiar with the RN sync, @acdlite does this change need to be propagated somewhere?

@FredyC is it possible you still have an older version of React in your dependencies? I know this is a common issue with ReactDOM, not sure if it's common with RN.

@danielkcz
Copy link
Author

danielkcz commented Apr 18, 2018

I am not sure that renaming changedBits is an actual issue here. If you look closely, it's seeking providerFiber.type.context and that's not there.

I checked and I have only React 16.3.2 installed in a whole tree, no other version there.

I will try updating to react-native 0.55 tomorrow, however that version was released before React 16.3, so it's unlikely there is a relevance.

@aweary
Copy link
Contributor

aweary commented Apr 18, 2018

Sorry, I misread that part. You can see in your screenshot it tries to read changedBits, which is also wrong. It's the same type of issue though. context was renamed to _context in #12501.

@gaearon
Copy link
Collaborator

gaearon commented Apr 19, 2018

I wouldn't expect react-native@0.54.2 to work with react@16.3.2. It specifies react@^16.3.0-alpha.1 as a peer dependency.

@gaearon gaearon closed this as completed Apr 19, 2018
@danielkcz
Copy link
Author

danielkcz commented Apr 19, 2018

Funny thing, it's actually working with react-native@0.55.3 even though it has peer dependency react@16.3.1. Apparently, it's not always reliable. Anyone stumbling into this error, just update ;)

@gaearon
Copy link
Collaborator

gaearon commented Apr 19, 2018

It’s expected. The internal naming changed in 16.3.1. So some versions of RN will only work with earlier versions, and some will work only with later versions. Use peer dependency as a guidance 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants