-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Discussion] Provide configuration through Context API #26
Comments
@ecwyne Thanks for the note 👍 I've actually been thinking about that as well. When I refactored My think is if we instantiate a Client with What do you think? |
I definitely think it's possible to make it so that you can pass different client parameters to different sub-trees and merge them with the configurations from parent providers. Eg. <FaunaProvider config={{ secret: 'secret1' }}>
<ComponentOne />
<FaunaProvider config={{ secret: 'secret2' }}>
<ComponentTwo />
</FaunaProvider>
<FaunaProvider config={{ observer: console.log }}>
<ComponentThree />
</FaunaProvider>
</FaunaProvider> |
I would suggest having a const useFaunaClient = () => {
const { config } = useContext(FaunaContext);
return new Client(config);
}; |
Awesome. I was definitely thinking something along these lines 🙌 I can imagine folks wanting to isolate data from different parts of their app in different DBs, which they can provide to pages/components through a |
Originally, I was thinking Something like this:
What do you think? Certainly not married to this implementation 😅 |
As written I believe Also, I'm not sure what you mean by In practice, I almost never think about the Fauna idea of a |
Instead of providing a
Client
instance to each hook, it would be much cleaner and more intuitive to provide client parameters through context.Prior art:
vercel/swr
@apollo/client
tannerlinsley/react-query
The text was updated successfully, but these errors were encountered: