diff --git a/examples/README.md b/examples/README.md index 834403cd2d1..28701fdbb16 100644 --- a/examples/README.md +++ b/examples/README.md @@ -16,6 +16,7 @@ you can view the source code within the folder or visit code sand box to see how | DefaultValues | https://codesandbox.io/s/react-hook-form-defaultvalues-n5gvx | | Default/Initial Form Value | https://codesandbox.io/s/l3mxpvmm9 | | Dirty/Touched/Submitted | https://codesandbox.io/s/7o2wrp86k6 | +| FormContext | https://codesandbox.io/s/sad-sutherland-zvfok | | Nested Fields | https://codesandbox.io/s/react-hook-form-nested-fields-mv1bb | | Normalize/Format/Mask Field | https://codesandbox.io/s/387z7njwzp | | Reset Form | https://codesandbox.io/s/jjm3wyqmjy | diff --git a/examples/formContext.tsx b/examples/formContext.tsx new file mode 100644 index 00000000000..5bf68eda7de --- /dev/null +++ b/examples/formContext.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import ReactDOM from "react-dom"; +import useForm, { FormContext, useFormContext } from "react-hook-form"; + +import "./styles.css"; + +function App() { + const methods = useForm(); + const { register, handleSubmit } = methods; + return ( + +
console.log(data))}> + + + + + + +
+ ); +} + +function Test() { + const data = useFormContext(); + return ; +} + +const rootElement = document.getElementById("root"); +ReactDOM.render(, rootElement);