Added usage test

This commit is contained in:
Matthew James
2018-03-03 08:26:02 +00:00
parent 3f1fafbac6
commit 4b342d3cf1
3 changed files with 37 additions and 3 deletions

View File

@@ -21,4 +21,4 @@ interface ReactResizeDetectorProps extends React.Props<ReactResizeDetector> {
declare class ReactResizeDetector extends React.PureComponent<ReactResizeDetectorProps> { }
export = ReactResizeDetector;
export default ReactResizeDetector;

View File

@@ -0,0 +1,31 @@
// Adapted from example provided at https://github.com/maslianok/react-resize-detector
import * as React from "react";
import * as ReactDOM from "react-dom";
import ReactResizeRouter from "./index";
class App extends React.PureComponent {
constructor(props: {}) {
super(props);
this.handleResize = this.handleResize.bind;
}
render(): JSX.Element {
return <div>
<div>Some child content</div>
<ReactResizeRouter
onResize={this.handleResize}
handleWidth
handleHeight
skipOnMount
resizableElementId="someElement" />
</div>;
}
private handleResize(width: number, height: number) {
console.log(`width = ${width}`);
console.log(`height = ${height}`);
}
}

View File

@@ -2,12 +2,14 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"jsx": "react",
"baseUrl": "../",
"typeRoots": [
"../"
@@ -17,6 +19,7 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts"
"index.d.ts",
"react-resize-detector-tests.tsx"
]
}