Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

formRef.current new key referring to form's html element #407

Open
xinxilas opened this issue Jun 3, 2021 · 0 comments
Open

formRef.current new key referring to form's html element #407

xinxilas opened this issue Jun 3, 2021 · 0 comments

Comments

@xinxilas
Copy link

xinxilas commented Jun 3, 2021

What would you like to be added:
add Reference to html node on formRef.current
(i.e formRef.current.el = <form>....</form> )

Why is this needed:
So I can change its style without the need to re-render the parent element
i.e
useEffect(() => formRef.current.el.disabled = isSubmitting, [isSubmitting])
useEffect(() => formRef.current.el.style = { opacity: isSubmitting ? 0.3 : null }, [isSubmitting])

Or what about get inputRefs nodes too?
useEffect(() => {
formRef.current.el.disabled = isSubmitting
formRef.current.fieldsEls.forEach(input => input.disabled = isSubmitting)
}, [isSubmitting])

so there is no need to send isSubmitting for each input and re-render them neither

....

Im struggling to control my parent component to render as minimal as possible, and this improved my renderings
(but accessing my parent element ref:
parentElement.current.querySelector('form'). disabled = isSubmitting

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant