Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
85 views
in Technique[技术] by (71.8m points)

javascript - How to use urql data in React like redux?

In one of our projects I'm using urql for graphql api calls. In other projects with RESTful api, I'm using redux to handle re-renders after each data changes.

I'm new in graphql and urql, for this case I should add redux and dispatch actions with new fetched data from urql or is there any trick to connect other components to cached urql data and use them?

Also, I've checked the main docs, but I didn't find any solution for this issue.

thanks

question from:https://stackoverflow.com/questions/66062407/how-to-use-urql-data-in-react-like-redux

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could try to do an update cache after changes in terms of data.

I would highly recommend you to read this, since they have got an clear example:

https://formidable.com/blog/2020/normalized-cache/

https://formidable.com/open-source/urql/docs/graphcache/cache-updates/

Once you did this, your components should always render the correct data.

I hope that this solves your problem.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...