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

Jotai Apollo: atomsWithQuery within react tree #11

Open
yassuge opened this issue Sep 1, 2023 · 4 comments
Open

Jotai Apollo: atomsWithQuery within react tree #11

yassuge opened this issue Sep 1, 2023 · 4 comments

Comments

@yassuge
Copy link

yassuge commented Sep 1, 2023

Hi Mo,

Currently, I'm working with the RedwoodApolloProvider and I'm finding
the use of the useApolloClient hook quite valuable for obtaining the
client. However, I've encountered a situation where I'm uncertain
about the best approach to handle it.

As far as I understand, Redwood doesn't offer a seamless method to
define the client outside of the React tree and then pass it to the
provider. This leads me to call atomsWithQuery from within the React
tree itself (to avoid calling hook for the client from outside the render function), as it requires the client to function properly. I'm
wondering if this pattern is supported or if you have any experience
with it. If so, I would greatly appreciate any insights or examples
you might have.

I've attempted a few methods, such as making a plain call (which
triggered infinite rerendering) and using useMemo (which didn't update
with new data), but I haven't found the ideal solution yet.

Thanks in advance for your assistance

@Aslemammad
Copy link
Collaborator

@dai-shi There was a pattern that supported creating atoms in the component body, I wonder if there's any documentation to it.

@dai-shi
Copy link
Member

dai-shi commented Sep 1, 2023

Do you mean something like this? https://twitter.com/dai_shi/status/1697396138578759985

@Aslemammad
Copy link
Collaborator

Aslemammad commented Sep 2, 2023 via email

@yassuge
Copy link
Author

yassuge commented Sep 4, 2023

looks like a good way to do, will try it out! thank you both

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

No branches or pull requests

3 participants