React: Cannot read property 'changedBits' of undefined

Created on 19 Apr 2018  路  6Comments  路  Source: facebook/react

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

Most helpful comment

Funny thing, it's actually working with [email protected] even though it has peer dependency [email protected]. Apparently, it's not always reliable. Anyone stumbling into this error, just update ;)

All 6 comments

Thanks for the report @FredyC . changedBits was renamed to _changedBits in https://github.com/facebook/react/pull/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.

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.

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 https://github.com/facebook/react/pull/12501.

I wouldn't expect [email protected] to work with [email protected]. It specifies react@^16.3.0-alpha.1 as a peer dependency.

Funny thing, it's actually working with [email protected] even though it has peer dependency [email protected]. Apparently, it's not always reliable. Anyone stumbling into this error, just update ;)

It鈥檚 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 馃檪

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jvorcak picture jvorcak  路  3Comments

framerate picture framerate  路  3Comments

huxiaoqi567 picture huxiaoqi567  路  3Comments

zpao picture zpao  路  3Comments

UnbearableBear picture UnbearableBear  路  3Comments