mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Added types for react-click-outside (#22985)
This commit is contained in:
committed by
Wesley Wigham
parent
91ad651732
commit
b47a6d3d07
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for react-click-outside 3.0
|
||||
// Project: https://github.com/kentor/react-click-outside
|
||||
// Definitions by: Christian Rackerseder <https://github.com/screendriver>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
import * as React from "react";
|
||||
|
||||
declare function enhanceWithClickOutside<P = {}>(wrappedComponent: React.ComponentClass<P>): React.ComponentClass<P>;
|
||||
|
||||
declare namespace enhanceWithClickOutside { }
|
||||
export = enhanceWithClickOutside;
|
||||
@@ -0,0 +1,30 @@
|
||||
import * as React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import * as enhanceWithClickOutside from 'react-click-outside';
|
||||
|
||||
interface Props {
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface State {
|
||||
isOpened: boolean;
|
||||
}
|
||||
|
||||
class StatefulComponent extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { isOpened: true };
|
||||
}
|
||||
|
||||
handleClickOutside() {
|
||||
this.setState({ isOpened: false });
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div>{this.props.text}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
const ClickOutsideStatefulComponent = enhanceWithClickOutside(StatefulComponent);
|
||||
|
||||
render(<ClickOutsideStatefulComponent text="" />, document.getElementById('test'));
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-click-outside-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user