You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I apologize if this is a silly question. I am trying to put together a Shopify app. There is a product creation flow, I want the form fields for the product details (name, price, pictures etc.) to render after a ResourcePicker returns (the user finishes selecting).
My initial intuition was to create a function and then put an if statement in it.
I noticed that the TextField loses focus after each character. Per this stackoverflow question this happens because the function is evaluated every time the state changes, and after each render, the textfield gets rendered unfocused.
One workaround is to wrap all of that in a div with display: none and once ResourcePicker returns a value, getElementById and update the display style manually. While this works, I was wondering if there is a recommended way (built in way in Polaris) of doing these kind of conditional renders ?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I apologize if this is a silly question. I am trying to put together a Shopify app. There is a product creation flow, I want the form fields for the product details (name, price, pictures etc.) to render after a ResourcePicker returns (the user finishes selecting).
My initial intuition was to create a function and then put an if statement in it.
I noticed that the TextField loses focus after each character. Per this stackoverflow question
this happens because the function is evaluated every time the state changes, and after each render, the textfield gets rendered unfocused.
One workaround is to wrap all of that in a
div
withdisplay: none
and onceResourcePicker
returns a value,getElementById
and update the display style manually. While this works, I was wondering if there is a recommended way (built in way in Polaris) of doing these kind of conditional renders ?Beta Was this translation helpful? Give feedback.
All reactions