Problem
I'm using yew-router with a STATE = (), and when I click back in the browser history I get this error message in my console log:
yew-router/src/service.rs:115
Could not deserialize state string
Steps To Reproduce
Happy to produce a minimal example if required.
I'm getting this problem with this version of the project I'm working on https://github.com/kellpossible/coster/tree/b3166d34cdafc88c40bfd2407be781fe991ca818
wasm-pack to be installed, then it should run with cargo run.localhost:8080New Tab buttonExpected behavior
No error message
Environment:
master1.43.0wasm32-unknown-unknownweb-sys version 0.3.3781.0.4044.113 (Official Build) Arch Linux (64-bit) and Firefox 75.0 (64-bit)Questionnaire
I'm interested in fixing this, but I'd like to do it a bit later after I understand the yew-router system a bit better. There's always a chance that I'm using it in the wrong way.
This is an implementation oversight that I made and haven't gotten around to fixing. Its because serde can't deserialize a string into (). Instead, an Empty or Empty{} struct could be created to be used instead of (), which should be able to be deserialized from "{}".
There might be some edge cases for this - like if it would properly deserialize an empty string as well. The Empty struct would have to have a custom Deserialize implemented for it to handle these edge cases.
Most helpful comment
This is an implementation oversight that I made and haven't gotten around to fixing. Its because serde can't deserialize a string into
(). Instead, anEmptyorEmpty{}struct could be created to be used instead of(), which should be able to be deserialized from "{}".There might be some edge cases for this - like if it would properly deserialize an empty string as well. The
Emptystruct would have to have a customDeserializeimplemented for it to handle these edge cases.