Debian Codegraph @

node/react-dropzone/typings/tests/basic.tsx

raw
1 import React from "react";
2 import Dropzone from "../../";
3 import { FileWithPath } from "file-selector";
4
5 export default class Basic extends React.Component {
6 state = { files: [] };
7
8 onDrop = (files: FileWithPath[]) => {
9 this.setState({
10 files,
11 });
12 };
13
14 render() {
15 return (
16 <section>
17 <div className="dropzone">
18 <Dropzone onDrop={this.onDrop}>
19 {({ getRootProps, getInputProps }) => (
20 <div {...getRootProps()}>
21 <input {...getInputProps()} />
22 <p>
23 Try dropping some files here, or click to select files to
24 upload.
25 </p>
26 </div>
27 )}
28 </Dropzone>
29 </div>
30 <aside>
31 <h2>Dropped files</h2>
32 <ul>
33 {this.state.files.map((f) => (
34 <li key={f.name}>
35 {f.name} - {f.size} bytes
36 </li>
37 ))}
38 </ul>
39 </aside>
40 </section>
41 );
42 }
43 }
44
45 export const optional = (
46 <Dropzone>
47 {({ getRootProps, getInputProps }) => (
48 <div {...getRootProps()}>
49 <input {...getInputProps()} />
50 </div>
51 )}
52 </Dropzone>
53 );