fabian-hiller / modular-forms

The modular and type-safe form library for SolidJS, Qwik and Preact
https://modularforms.dev
MIT License
1.05k stars 55 forks source link

[React] Feature Request: Decouple Form and FormStore creation from components. #209

Open zthng opened 6 months ago

zthng commented 6 months ago

Hello, is it possible to explore decoupling the creation of the signals store from the creation of the components?

Reason: This would enable us to build form modules that are totally isolated from React (with only @preact/signals-react as the only dependency remaining) and to manipulate the form fully outside of React.

Since it is a signal, we can consume it anytime we like anyway—and as such, we can do the bindings between the modules and React ourselves.

This is from the perspective of a large-scale form. Doing this will allow us to break the form into multiple instances without requiring React to have the component rendered somewhere.

fabian-hiller commented 6 months ago

Not yet, but it will be in the future. I plan to develop a signal-based and framework-agnostic core that can be plugged into framework-specific components.

What you can do today is replace useForm with useFormStore and then pass the result to child components.

zthng commented 6 months ago

So technically, I could reimplement the guts of the useFormStore hook and pass it anywhere I guess. I'll try that out 😂