open-source-labs / Reactime

Developer tool for time travel debugging and performance monitoring in React applications.
https://www.reacti.me
MIT License
2.17k stars 200 forks source link

Cannot read property 'match' of undefined using array destructuring #215

Closed staeke closed 3 years ago

staeke commented 4 years ago

This code

const [a,{b}] useState([0,{}])

fails with Cannot read property 'match' of undefined. It's because of the somewhat simplistic AST traversal in src/backend/helpers.ts, line 128. This line:

if (el.match(/_use/)) hooksNames[el] = statements[i + 1];

I could a submit a PR, but don't fully understand the code, and thought you'd probably do it better.

Thanks anyhow!

kevinfey commented 4 years ago

Hi staeke - can You link to the repo where You're having this issue?

lind-tania commented 3 years ago

Hi, The traversal function was updated in version 7 of Reactime.