I have a problem I can't get the data values from the formContent component. Can you help me please. You will find the codesandbox link
I have a problem I can't get the data values from the formContent component. Can you help me please. You will find the codesandbox link
You need to wrap your App (root component) with the AppContext provider.
AppContext from formContent to App component and create context with values and setters and other functions you want.export const AppContext = createContext({
activeStep: 0,
values: [],
handleFormChange() {},
handleNext() {},
handleBack() {}
});
export default function App() {
const [values, setValues] = useState({
nni: "",
nom: "",
prenom: "",
email: "",
typeHabilitation: "",
perimetreHabilitation: ""
});
return (
<AppContext.Provider value={{ values, setValues }}>
<Form />
</AppContext.Provider>
);
}
formulaireValidation and SummaryForm components.export default function formulaireValidation({ submitForm }) {
...
...
const { values, setValues } = useContext(AppContext);
...
...
}
export default function SummaryForm(props) {
const { values, handleBack, handleNext } = useContext(AppContext);
...
...
}
Working Demo