Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useReactive can't set formData to state #1024

Closed
rimsila opened this issue Jul 11, 2021 · 1 comment · Fixed by #2079
Closed

useReactive can't set formData to state #1024

rimsila opened this issue Jul 11, 2021 · 1 comment · Fixed by #2079
Assignees

Comments

@rimsila
Copy link

rimsila commented Jul 11, 2021

const state = useReactive({
logoFormData: undefined
})
const [logoForm, setLogoForm]= useState(undefined)

// I want upload later so I just save formData to state
   state.logoFormData = formData;
  setLogoForm(formData)
  
  // call api service
  - run api upload ==> runUpload(state.logoFormData) not working it become object like picture 1
  - run api upload ==> runUpload(logoForm)  working see picture 2

picture1 useReactive

Screen Shot 2021-07-11 at 2 19 01 PM

picture 2 useState

Screen Shot 2021-07-11 at 2 22 00 PM

@awmleer awmleer self-assigned this Jul 12, 2021
@liuyib liuyib self-assigned this Feb 23, 2023
@liuyib liuyib added this to To do in ahooks tasks via automation Feb 23, 2023
@liuyib liuyib moved this from To do to In progress in ahooks tasks Feb 25, 2023
@liuyib
Copy link
Collaborator

liuyib commented May 8, 2023

被这个 PR 一并修复了,都是同一类问题。验证地址:https://codesandbox.io/s/ahooks-issue-1024-lcfctl?file=/App.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
ahooks tasks
In progress
Development

Successfully merging a pull request may close this issue.

3 participants