Shopify / ui-extensions

MIT License
269 stars 35 forks source link

Patches 2024-10 with support for UI Extension unmounting in host to enable teardown functions in client #2482

Closed js-goupil closed 5 days ago

js-goupil commented 5 days ago

Background

We recently added support for unmounting UI Extensions in the host to enable teardown functions in the client. This was by implementing the new createRoot function, and returning the callback from that function

Solution

This cherry picks the necessary changes into a patch for 2024-10

🎩

  1. In the host you will need to call the callback from the render function when you unmount the UI Extension.
  2. In the client, you can test a useEffect teardown function with a console log to make sure the teardown is being called.

Checklist

github-actions[bot] commented 5 days ago

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset directory. If the changes are user-facing and should cause a version bump, run yarn changeset to track your changes and include them in the next release CHANGELOG. If you are making simple updates to repo configuration, examples, or documentation, you do not need to add a changeset.