question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property ' __value' of undefined

See original GitHub issue

Testing under jest, this line throws an error calling fromreact-navigation-drawer. This test executes via the mock as expected in version 1.4.0 and then it breaks in 1.5.0 and later.

https://github.com/software-mansion/react-native-reanimated/blob/33f827311f035eaed430d82b057edc6e00781ec7/mock.js#L26

    TypeError: Cannot read property ' __value' of undefined

      15 |   beforeEach(async () => {
      16 |     store = mockStore({ metricsState: initialMetricsState, preferencesState: initialPreferencesState });
    > 17 |     container = mount(
         |                 ^
      18 |       <Provider store={store}>
      19 |         <RootContainer />
      20 |       </Provider>,

      at getValue (node_modules/react-native-reanimated/mock.js:26:14)
      at getValue (node_modules/react-native-reanimated/mock.js:105:11)
      at new cond (node_modules/react-navigation-drawer/lib/commonjs/views/Drawer.tsx:325:9)
      at constructClassInstance (node_modules/react-dom/cjs/react-dom.development.js:14204:18)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:18413:5)
      at beginWork$1 (node_modules/react-dom/cjs/react-dom.development.js:20186:16)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:336:14)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:385:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:440:31)
      at beginWork$$1 (node_modules/react-dom/cjs/react-dom.development.js:25780:7)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:24698:12)
      at workLoopSync (node_modules/react-dom/cjs/react-dom.development.js:24671:22)
      at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:24270:11)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:23698:7)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:27103:3)
      at node_modules/react-dom/cjs/react-dom.development.js:27528:7
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:24433:12)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:27527:5)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:27608:10)
      at render (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:437:26)
      at fn (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:354:37)
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:24386:12)
      at Object.act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
      at act (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:354:13)
      at Object.wrapAct [as render] (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:423:16)
      at new render (node_modules/enzyme/src/ReactWrapper.js:115:16)
      at mount (node_modules/enzyme/src/mount.js:10:10)
      at mount (__tests__/rootContainer.test.tsx:17:17)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at Generator.invoke [as _invoke] (node_modules/regenerator-runtime/runtime.js:271:22)
      at Generator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:45:40)
      at invoke (node_modules/regenerator-runtime/runtime.js:135:20)
      at node_modules/regenerator-runtime/runtime.js:170:11
      at new Promise (node_modules/core-js/modules/es6.promise.js:177:7)
      at callInvokeWithMethodAndArg (node_modules/regenerator-runtime/runtime.js:169:16)
      at AsyncIterator.enqueue (node_modules/regenerator-runtime/runtime.js:192:13)
      at AsyncIterator.prototype.<computed> [as next] (node_modules/regenerator-runtime/runtime.js:97:21)
      at Object.<anonymous>.exports.async (node_modules/regenerator-runtime/runtime.js:216:14)
      at Object._callee (__tests__/rootContainer.test.tsx:15:14)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jakub-gonetcommented, Jun 14, 2020

@GoMino, @GioCirque, thanks for reporting.

@Thomazella, thanks for the detailed description. I think NOOP returning 1 as __value isn’t right fix because we return 0 when starting or stopping the clock.

Can you guys check out if https://github.com/software-mansion/react-native-reanimated/commit/c9cabc468e8a94eb07c91cb2bcaa87dfb188d3fa commit improves the situation a bit?

1reaction
tcodes0commented, Mar 3, 2020

This: https://github.com/software-mansion/react-native-reanimated/blob/79f31870b5f38d62ee56a5116dc0962381f86c61/mock.js#L138 has type: https://github.com/software-mansion/react-native-reanimated/blob/79f31870b5f38d62ee56a5116dc0962381f86c61/react-native-reanimated.d.ts#L285

but it’s being mocked as NOOP a function that returns void. https://github.com/software-mansion/react-native-reanimated/blob/79f31870b5f38d62ee56a5116dc0962381f86c61/mock.js#L14 Then the code complains __value is not there bc nothing was returned.

Not sure if best fix but see (actually probably best to change just cond to return an object) https://github.com/lucianomlima/react-navigation-v4-examples/pull/1

PS: key lines in stacktrace:

at getValue (node_modules/react-native-reanimated/mock.js:26:14)
      at getValue (node_modules/react-native-reanimated/mock.js:105:11)
      at new cond (node_modules/react-navigation-drawer/lib/commonjs/views/Drawer.tsx:325:9)
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'value' of Undefined in JS
To solve the "Cannot read property 'value' of undefined" error, make sure that the DOM element you are accessing exists. The error is...
Read more >
Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >
Uncaught TypeError: Cannot read property 'value' of undefined
I have some JavaScript code that gives this error. Uncaught TypeError: Cannot read property 'value' of undefined.
Read more >
[SOLVED] Cannot Read Property of Undefined in JavaScript
The “cannot read property of undefined” error occurs when you attempt to access a property or method of a variable that is undefined...
Read more >
Uncaught TypeError : Cannot read properties of undefined
The root cause of the error is that the declared variable doesn't have any value, so by default, JavaScript treats all variables as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found