-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update POS render function to use createRoot #2353
base: unstable
Are you sure you want to change the base?
Conversation
packages/ui-extensions-react/src/surfaces/point-of-sale/render.tsx
Outdated
Show resolved
Hide resolved
We detected some changes in |
try { | ||
remoteRender( | ||
const remoteRoot = createRoot(root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not exactly sure what else would be required in this file, but this seems to work properly. Also it would be nice to know if this change is desired elsewhere. @vividviolet you mentioned we could just share this function implementation instead of having it be duplicated everywhere.
@NathanJolly Testing this on main of POS without any changes as seen in my other draft PR seems to work just fine. However, I don't feel the need to squeeze this in for 2024-10. If anything breaks on POS because of something we didn't test, well it just doesn't feel worth the risk right now. But perhaps while I'm on intermission you guys can ship this once the 2024-10 cut as been made, and then we can implement the appropriate changes on POS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think we should share this fix with other surface areas to be consistent
packages/ui-extensions-react/src/surfaces/point-of-sale/render.tsx
Outdated
Show resolved
Hide resolved
packages/ui-extensions-react/src/surfaces/point-of-sale/render.tsx
Outdated
Show resolved
Hide resolved
packages/ui-extensions-react/src/surfaces/point-of-sale/render.tsx
Outdated
Show resolved
Hide resolved
1625924
to
f84072f
Compare
f84072f
to
547404d
Compare
@vividviolet Updated the PR to move the logic into a shared util function. I can update the admin UI Extension with another commit in this PR if you want, or we can wait until you guys are ready down the line? |
Can you please add it for admin as well? I think we do want it for the upcoming Oct release. I'll test the PR for Admin. |
done |
d7c898e
to
dccb7f8
Compare
dccb7f8
to
0c8f546
Compare
Background
Currently all of our teardown functionality does not work. For example, the return method from a useEffect does not work in UI Extensions for POS (and I think on the other surfaces it's also broken?).
Solution
This replaces the deprecated render call with the
createRoot
function, which returns a root which has arender
function, and anunmount
function. We are passing the unmount method into thePromise.resolve
, which means that it can be used on the host side to properlyunmount
everything when POS unmounts theUIExtensionContainer
.🎩
You can tophat this on POS with the following POS Branch: https://github.com/Shopify/pos-next-react-native/pull/42289
esm/surfaces/point-of-sale/render.mjs
file that gets generated. Copy the contents.node_modules/@shopify/ui-extensions-react/build/esm/surfaces/point-of-sale/render.mjs
.Checklist