https://github.com/danielpza/simple-form-state-example
https://github.com/danielpza/simple-form-state-example
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielpza/simple-form-state-example
- Owner: danielpza
- Created: 2021-11-19T18:57:53.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-19T19:32:37.000Z (over 4 years ago)
- Last Synced: 2026-04-08T22:34:11.740Z (2 months ago)
- Language: TypeScript
- Size: 364 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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;
```