Can I use the Tauri backend as an alternative to Redux or useState()? #4940
-
Just wondering, do I need to use Redux to have a global State on React since I have a backend in Rust? Can I use Events to transfer data between client and server and have the state work as dynamically as in Redux or useState()? Or is there any other method to use Tauri backend as "Redux" state manager? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can't really replace useState(), but Redux may be possible if you currently aren't "abusing" Redux. Just keep in mind that setting/receiving the state will be slightly slower because of the IPC round trip. Shouldn't be noticeable unless you're sending >1mb payloads. That said, i do use tauri::State as a cache for my routes too, especially to handle page refreshes. |
Beta Was this translation helpful? Give feedback.
You can't really replace useState(), but Redux may be possible if you currently aren't "abusing" Redux. Just keep in mind that setting/receiving the state will be slightly slower because of the IPC round trip. Shouldn't be noticeable unless you're sending >1mb payloads.
Oh and not to forget, Tauri's api are async, mentioning it in case it's a no-go for you.
That said, i do use tauri::State as a cache for my routes too, especially to handle page refreshes.