Last active
September 22, 2020 14:41
-
-
Save almazmusic/c18fb70f79ab33deaf9e37e39d0f1fd0 to your computer and use it in GitHub Desktop.
reduxForm typing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { InjectedFormProps, reduxForm } from "redux-form"; | |
type FormType = { | |
input1: string; | |
}; | |
type ComponentProps = {}; | |
type InjectedProps = InjectedFormProps<FormType, ComponentProps>; | |
const Form: React.FunctionComponent<InjectedProps & ComponentProps> = ({ | |
handleSubmit, | |
}) => { | |
const onSubmit = (values: FormType) => { | |
console.log("values", values); | |
}; | |
return ( | |
<form onSubmit={handleSubmit(onSubmit)}> | |
<input type="text" name="input1" /> | |
</form> | |
); | |
}; | |
export const TrackingAdd = reduxForm<FormType, ComponentProps>({ | |
form: "test.form", | |
enableReinitialize: true, | |
keepDirtyOnReinitialize: true, | |
})(Form); |
Thanks! This was just too hard to figure out without any documentation...
Glad, that this helps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! This was just too hard to figure out without any documentation...