Skip to content
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

Allow components to _either_ use context provider or use props #629

Open
1 of 3 tasks
frehner opened this issue Dec 1, 2022 · 5 comments
Open
1 of 3 tasks

Allow components to _either_ use context provider or use props #629

frehner opened this issue Dec 1, 2022 · 5 comments

Comments

@frehner
Copy link
Contributor

frehner commented Dec 1, 2022

Quite a few components rely on a context provider and associated hook, but in many cases it may also make sense to allow devs to pass in a prop instead and not rely on setting up a context provider.

For example, <Metafield/> uses useShop(), but only need the locale from it. We could also allow a locale prop and not rely on the useShop() hook in that case.

Tasks

@frehner frehner self-assigned this Jan 4, 2023
@frehner
Copy link
Contributor Author

frehner commented Jan 4, 2023

@frehner
Copy link
Contributor Author

frehner commented Jan 11, 2023

Hm, while it makes sense for easy ones like locale to be either a prop or from context, I'm less sure on complex ones, like those that come from the CartProvider.

@elisenyang
Copy link
Contributor

prop should override context

if no prop value is provided - we default to context

@frehner
Copy link
Contributor Author

frehner commented Jan 24, 2023

We should also update CartProvider to optionally pull from ShopifyConfig the contryCode.

@frehner
Copy link
Contributor Author

frehner commented Jan 24, 2023

Decision: leave the useCart() things alone for now, as there is more complexity there, but allow places that use useShop() to optionally take in a prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants