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.

trackExtraHooks cannot set property of #<Object> which has only a getter

See original GitHub issue

By specifying trackExtraHooks, the following error is thrown. NOTE: The error is only thrown when running in local machine, NOT in codesandbox.

Reproduction link: Edit why-did-you-render-test

whyDidYouRender.js:167 Uncaught TypeError: Cannot set property useSelector of #<Object> which has only a getter
    at whyDidYouRender.js:167
    at Array.forEach (<anonymous>)
    at zn (whyDidYouRender.js:150)
    at Module../src/index.js (index.js:9)
    at __webpack_require__ (bootstrap:785)
    at fn (bootstrap:150)
    at Object.1 (styles.css?f684:43)
    at __webpack_require__ (bootstrap:785)
    at checkDeferredModules (bootstrap:45)
    at Array.webpackJsonpCallback [as push] (bootstrap:32)
    at main.chunk.js:1
(anonymous) @ whyDidYouRender.js:167
zn @ whyDidYouRender.js:150
./src/index.js @ index.js:9
__webpack_require__ @ bootstrap:785
fn @ bootstrap:150
1 @ styles.css?f684:43
__webpack_require__ @ bootstrap:785
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.chunk.js:1
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:34
  • Comments:54

github_iconTop GitHub Comments

59reactions
nour-scommented, Mar 9, 2020

I’m using CRA, and I managed to get around it by doing:

if (process.env.NODE_ENV === 'development') { whyDidYouRender(React, { trackAllPureComponents: true, trackHooks: true, trackExtraHooks: [[require('react-redux/lib'), 'useSelector']], }); }

15reactions
DalderupMauricecommented, Feb 22, 2020

How are we able to fix this without ejecting the webpack config? I am unable to use the library as intended with this issue and IMO it shouldn’t be low priority/wontfix at all as a lot of people use CRA and will probably experience the same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot set property createElement of #<Object> which is only ...
The main problem is that in the webpack config react module is resolved to preact-compat which apparently does not allow setting new values...
Read more >
trackExtraHooks cannot set property of #<Object> which has ...
trackExtraHooks cannot set property of # which has only a getter. ... NOTE: The error is only thrown when running in local machine, ......
Read more >
TypeError: setting getter-only property "x" - JavaScript | MDN
TypeError: Cannot set property x of #<Object> which has only a getter (V8-based) TypeError: setting getter-only property "x" (Firefox) TypeError: Attempted ...
Read more >
Uncaught TypeError: Cannot set property window of ...
... Cannot set property window of #<Window> which has only a getter ... In JavaScript almost everything is an object, null and undefined...
Read more >
Alex Siman - Medium
your code sandbox is broken: TypeError. Cannot set property useSelector of #<Object> which has only a getter.
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