-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Watch changes without rerender #912
Comments
hi, in order to get a new updated value, you will have to invoke the function in this particular example is your |
I don't mean to place listener in my component, imagine if listener is a standalone function. then invoking it won't rerender our component. const component = () => {
const form = useForm({listener});
return <Anything />
}
// it can be invoke without forcing any component to rerender
function listener(data) {
autoSaveTobackend(data);
} |
you can achieve this by attach |
not going to waste this idea tho, adding to my backlog |
Hi @bluebill1049 facing the same issue here watching a single field (an isolated child component) seems to trigger a rerender of the parent component and any other watched child components |
I think an easy option for this would be very nice. It's a common use-case to update some fields as soon as others have changed. |
This would be really useful to me too. I've had to jump through some serious hoops to get a combination of remote loading values and autosaving fields to work because of not being able to watch for changes without rerendering/setting values without triggering watch etc. |
try useWatch, you can isolate that re-render. |
Hi, How can I manage this?
It still re-renders when I use "UseWatch, something to do with the change of control/errors I think .. |
|
Is there any ways to unsubscribe from watching values change? |
until unmount. |
I'm using "react-hook-form": "^7.6.4" When I do,
when the callback triggers, it doesnt seem a re-render happens. is this the way to make re-render not happen? |
By subscribing to watch: ` ` |
useWatch did the trick to me, I pass control in the component, const data = useWatch({ control }) and only that component re-renders on updates. Perfect! I spent so much time trying to fix this in formik that I cheered when it worked with react-hook-form ;) Thanks guys! |
I just wanted to check if the form was modified after a certain stage without needing the actual value of the fields and this worked for me! |
@gowthamvbhat |
@ali-shabani Thanks a lot! This felt much cleaner to implement. |
id like to hear an update about this.. |
Canary Mail
You've received a secure email
***@***.*** has sent you a secure email via Canary Mail.
Read Secure Email (https://secure.canarymail.io/read?obj_id=84193181-a6c7-4ca1-b9d7-f4c2c1a7f625&obj_key=R2VKYnkwd0hoQ09zYWhqem1yQ2o0UT09&thr_id=84193181-a6c7-4ca1-b9d7-f4c2c1a7f625)
If you expect to correspond often with ***@***.***, we recommend you download Canary Mail for free.
Download Canary (https://canarymail.io)
Privacy (https://canarymail.io/privacy.html) | Terms (https://canarymail.io/terms.html) | Docs (https://help.canarymail.io/) | Support (https://canarymail.zendesk.com/hc/en-us/requests/new)
Copyright © 2021 Canary Mail, All rights reserved.
|
Hi, there is an option in react form hook that we can watch values change. but there is a problem with it that every time a watching variable changes a re render occur in my components. I know you have a solution in advanced part to use memozation to reduce re renders. but I want a way to listen to variables change without any re rendering. I think it should be handle by adding extra argumnet in useForm function for listening to changes. there should be a function as argument to pass to useForm to called every once a change occurs;
The text was updated successfully, but these errors were encountered: