mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge pull request #15016 from sjpurol/withHandlers-factory
recompose: withHandlers may take a factory function
This commit is contained in:
Vendored
+3
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Recompose v0.20.3
|
||||
// Type definitions for Recompose v0.22.0
|
||||
// Project: https://github.com/acdlite/recompose
|
||||
// Definitions by: Iskander Sierra <https://github.com/iskandersierra>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -50,8 +50,9 @@ declare module 'recompose' {
|
||||
type HandleCreators<TOutter> = {
|
||||
[handlerName: string]: mapper<TOutter, EventHandler>;
|
||||
};
|
||||
type HandleCreatorsFactory<TOutter> = (initialProps: TOutter) => HandleCreators<TOutter>;
|
||||
export function withHandlers<TInner, TOutter>(
|
||||
handlerCreators: HandleCreators<TOutter>
|
||||
handlerCreators: HandleCreators<TOutter> | HandleCreatorsFactory<TOutter>
|
||||
): ComponentEnhancer<TInner, TOutter>;
|
||||
|
||||
// defaultProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#defaultprops
|
||||
|
||||
@@ -73,6 +73,12 @@ function testWithHandlers() {
|
||||
onSubmit: (props: OutterProps) => (e: any) => {},
|
||||
});
|
||||
const enhanced: React.ComponentClass<OutterProps> = enhancer(innerComponent);
|
||||
|
||||
const enhancer2 = withHandlers((props: OutterProps) => ({
|
||||
onChange: (props: OutterProps) => (e: any) => {},
|
||||
onSubmit: (props: OutterProps) => (e: any) => {},
|
||||
}));
|
||||
const enhanced2: React.ComponentClass<OutterProps> = enhancer2(innerComponent);
|
||||
}
|
||||
|
||||
function testDefaultProps() {
|
||||
|
||||
Reference in New Issue
Block a user