[redux-form] Allow the "reduxForm()" function to wrap stateless functional

components and not just class components.
This commit is contained in:
Matt C
2017-02-24 09:59:00 +11:00
parent 7c2a4738ea
commit def2102ff9
2 changed files with 9 additions and 1 deletions
+3 -1
View File
@@ -1,5 +1,6 @@
import {
Component,
StatelessComponent,
ReactElement,
SyntheticEvent,
ReactEventHandler,
@@ -20,7 +21,8 @@ export function reduxForm(
): FormDecorator<any, any, any>;
export interface FormDecorator<FormData extends DataShape, P, S> {
<T extends (typeof Component)>(component: T): T & Form<FormData, P, S>;
<T extends (typeof Component | StatelessComponent<any>)>(component: T):
T & Form<FormData, P, S>;
}
export interface Config<FormData extends DataShape, P, S> {
+6
View File
@@ -50,3 +50,9 @@ class MyForm extends Component<{}, {}> {
);
}
}
const MyStatelessFunctionalComponent: React.SFC<void> = () => <div/>;
reduxForm({
form: 'mySFCForm'
})(MyStatelessFunctionalComponent);