Valtio state async properties #91
Closed
italodeandra
started this conversation in
General
Replies: 1 comment 1 reply
-
Just put a promise afterward. const state = proxy({})
const userClicked = () => {
state.result = fetch(url).then(res => res.json())
} There's no notion of "data is requested" as it's just an object... |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If I understand correctly, when using async (like fetch on the example) data, it will be fetched as soon as the proxy is created (but it will be suspended until the data is ready).
Is it possible to only fetch after the data is requested for the first time? Because I have some remote data that will only be used on a specific page that is not open. And I want it to be fetched only if the user navigates to it.
Beta Was this translation helpful? Give feedback.
All reactions