You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mutate() with passing synchronous callback like below.
Inputing English is fine, but if I input Japanese IME, e.target.value get a bunch of duplicate characters.
I recommend you to use keep a local copy of the state for the input in your component and use mutate when you want to actually save it. Remember SWR could revalidate your key in different scenarios, using it directly as the value of your input could cause an unexpected rollback if SWR revalidate the data.
Bug report
Description / Observed Behavior
I'm using mutate() with passing synchronous callback like below.
Inputing English is fine, but if I input Japanese IME,
e.target.value
get a bunch of duplicate characters.Expected Behavior
When I input 'n' first, then 'a', the title will expected to be 'な' (Japanese).
However actual result is unstable, it may be like 'なな', 'nな', 'な' etc.
Additional Context
SWR version. @0.3.5
This bug may related to facebook/react#3926, caused by asynchronous onChange handler with IME input.
When I dig the source code, it seems that even if I pass a synchronous callback, that function is executed internally with await. https://github.com/vercel/swr/blob/master/src/use-swr.ts#L143
If I patch like below, I get a result as expected. However according to the #619, this seems to cause another bug.
The text was updated successfully, but these errors were encountered: