pomber / didact

A DIY guide to build your own React
https://pomb.us/build-your-own-react/
6.29k stars 531 forks source link

Reconciliation is too naive #19

Open RobinClowers opened 4 years ago

RobinClowers commented 4 years ago

Hey there, I really appreciate your tutorial, great stuff.

That said, the way you handle reconciliation leads to bugs if things are conditionally rendered. I've forked your codesandbox to show the issue: https://codesandbox.io/s/didact-8-0l4lz. You should see that clicking the show / hide button will duplicate the count element. Note that if you first increment the count it works correctly, it's not obvious to me why that is.

Cheers!

sschottler commented 4 years ago

This open PR fixes the issue: https://github.com/pomber/didact/pull/17