react-native-paper icon indicating copy to clipboard operation
react-native-paper copied to clipboard

fix: fix logic error in PortalHost update method

Open seancheung opened this issue 4 years ago • 4 comments
trafficstars

Summary

It seemed to be a typo

Test plan

Re-mount PortalHost component

seancheung avatar Feb 24 '21 17:02 seancheung

Hey @seancheung, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

callstack-bot avatar Feb 24 '21 17:02 callstack-bot

Hello 👋, this pull request has been open for more than 2 months with no activity on it. If you think this is still necessary with the latest version, please comment and ping a maintainer to get this reviewed, otherwise it will be closed automatically in 7 days.

github-actions[bot] avatar Apr 26 '21 00:04 github-actions[bot]

Hey @seancheung, I have the felling like I don't have enough context to understand that change. Could you please specify more details about that fix or what was the issue?

lukewalczak avatar May 06 '21 12:05 lukewalczak

const index = this.queue.findIndex(
-       (o) => o.type === 'mount' || (o.type === 'update' && o.key === key)
+       (o) => (o.type === 'mount' || o.type === 'update') && o.key === key
      );

@lukewalczak

About what the code does:

When a Portal mounts before its Host being mounted, a mount operation will be queued. And when that Host mounts, all queued operations will be consumed. But if that Portal updates(which is an update operation) while the consuming process is not over yet, any mount or update operation from the same Portal(identified by key) should be flushed to avoid duplicate dispatching(which leads to unexpected re-rendering or even an exception).

About what I fixed:

I think it's a typo which unexpectedly finds any operation in queue with the type mount even it has a different key. This happens(rarely) when a portal mounts while there are queued operations from other portals, which will be flushed unexpectedly.

seancheung avatar May 07 '21 14:05 seancheung