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.

useHash: Cannot read properties of undefined (reading 'substring')

See original GitHub issue

The argument here passed to the callback

https://github.com/kyeotic/raviger/blob/10d24e63b6c9f9329cc34df6365c639fca5cc529/src/location.ts#L78-L84

is an Event object from the hashchange here

https://github.com/kyeotic/raviger/blob/10d24e63b6c9f9329cc34df6365c639fca5cc529/src/location.ts#L87

It doesn’t have a hash property.

Maybe consistently use window.location.hash and ignore the argument altogether.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kyeoticcommented, Nov 2, 2022

I don’t understand how this one got around our tests. Does jsdom produce invalid hashchange events? I’m also surprised it took this long to find.

0reactions
kyeoticcommented, Nov 2, 2022

Oof, terrible first impression. Thank you for reporting the bug and not just moving on 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'substring' of undefined in react
My hypothesis is that you get undefined because you are trying to see the result without have some async/await in place (or some...
Read more >
Cannot read Property 'substring' of Undefined in JavaScript
The "Cannot read property 'substring' of undefined" error occurs when calling the `substring()` method on an `undefined` value. To solve the error, ...
Read more >
TypeError: Cannot read property 'substr' of undefined #4275
While everything worked during development now suddenly cloning a fresh repo fails with TypeError: Cannot read property 'substr' of ...
Read more >
JavaScript Hash Table – Associative Array Hashing in JS
Hash Tables are a data structure that allow you to create a list of paired values. You can then retrieve a certain value...
Read more >
css-loader | webpack - JS.ORG
string - disables CSS Modules for all files and set the mode option, more information you can read here; object - enable CSS...
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