An open API service indexing awesome lists of open source software.

https://github.com/danielpza/simple-form-state-example


https://github.com/danielpza/simple-form-state-example

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# Form helper example (similar to formik)

How to use:

```tsx
// App.tsx
import React from "react";
import { createStateHandler } from "./state-handler";

const [StateContext, useState, withState] = createStateHandler<{
firstName: string;
lastName: string;
range: {
start: number;
end: number;
};
}>();

const TextField = withState("input");

function Form() {
return (
<>




>
);
}

function App() {
const [state, onChange] = useState({
firstName: "",
lastName: "",
range: {
start: 0,
end: 0,
},
});

return (
<>



{JSON.stringify(state, null, 2)}

>
);
}

export default App;

```