cfaester / enzyme-adapter-react-18

MIT License
38 stars 12 forks source link

fix: reading reactInternals from null instance #6

Closed sienic closed 1 year ago

sienic commented 1 year ago

The onRenderCb sets the instance after getNode() gets called, which inside the wrapAct tries to access the _reactInternals property of instance (by that time null), thus raising TypeError: Cannot read properties of null (reading '_reactInternals').

cfaester commented 1 year ago

Hi, @sienic - great PR, I'll take a look at it 👍

thecristen commented 1 year ago

I tried this while working to migrate a repo with hundreds of Enzyme tests to React 18. While I still have some failing tests (around not finding nodes it used to be able to find), this PR did successfully fix the TypeError: Cannot read properties of null (reading '_reactInternals') error. Thanks! 🎩

cfaester commented 1 year ago

Looks great @sienic . This will be hitting 0.7.0 later today.