Closed danwetherald closed 2 years ago
That's true! Thanks for reporting.
Here goes a simple demonstration of it:
Put the provider somewhere in the top of your tree https://github.com/Astrocoders/reform/blob/master/packages/demo/src/modules/PostAddNext.re#L67
Now you can consume the context with YourForm.Field
component or YourForm.useFormContext
hook
Would you have an example of the use of the useFormContext hook?
It feels a bit weird that it returns an optional, any best practices here?
@dan003400 We're working on a new version of the documentation website. Probably we'll document the best practices for this case.
It feels a bit weird that it returns an optional, any best practices here?
@fakenickels can you explain this?
it's in the case you forgot to put the Provider on top of the tree. We sacrificed the usability a bit in exchange for a bit more of safety but we might revisit that as it's very annoying.
@dan003400 We have a WIP PR that adds missing docs for the context. Check out #238 and https://deploy-preview-238--rescript-reform.netlify.app/docs/field please 😄
@dan003400 The documentation for the context api is live: https://reform.rescriptbrasil.org/docs/use-form-context
There does not seem to be an example or documentation referring to any form context as advertised in the read me.
https://github.com/Astrocoders/reform/blob/master/README.md#L165