airbnb / goji-js

React ❤️ Mini Program
https://goji.js.org
MIT License
224 stars 27 forks source link

Move `instance.registerEventHandler` from `createInstance` to `commitMount` in the React reconciler host config #229

Closed malash closed 1 year ago

malash commented 1 year ago

According to the doc of createInstance of React reconciler, we should register event handle in the commitMount hook instead of createInstance. Otherwise, it may cause a memory leak problem with error bonding or suspense.

For more details, please see the packages/core/src/reconciler/__tests__/commitMount.test.tsx file in this PR. The reproduction demo is inspired from https://github.com/facebook/react/issues/20271#issuecomment-728526557 .