DefinitelyTyped/types/react-resizable/react-resizable-tests.tsx
Harry Brundage 8be301717e
Add typings for react-resizable
- Package structure created via dtsgen
 - Initial typings generated from package version 1.7 using flow2ts
 - Types and tests edited by me to be nice and crispy
 - I am using this in a project myself and I figured it's time to upstream!
2019-02-22 19:53:36 -05:00

50 lines
1.3 KiB
TypeScript

import * as React from "react";
import { Resizable, ResizableBox, ResizeCallbackData } from "react-resizable";
const resizeCallback = (
event: React.SyntheticEvent,
data: ResizeCallbackData
) => {
console.log(data.size.height);
console.log(data.node);
};
class TestResizableComponent extends React.Component {
render() {
return (
<Resizable
width={10}
height={20}
axis="y"
className={"foobar"}
minConstraints={[20, 20]}
maxConstraints={[42, 42]}
handleSize={[5, 5]}
lockAspectRatio={false}
draggableOpts={{ opaque: true }}
onResizeStart={resizeCallback}
onResizeStop={resizeCallback}
onResize={resizeCallback}
>
<div>{this.props.children} </div>
</Resizable>
);
}
}
class TestResizableBoxComponent extends React.Component {
render() {
return (
<ResizableBox
width={10}
height={20}
onResizeStart={resizeCallback}
onResizeStop={resizeCallback}
onResize={resizeCallback}
>
<div>{this.props.children}</div>
</ResizableBox>
);
}
}