-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathindex.js
46 lines (41 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
// import App from './App';
import registerServiceWorker from './registerServiceWorker';
import List from './list';
const Data = [];
for (let index = 0; index < 20; index++) {
Data.push({ name: index + 1, o: index });
}
class C extends React.Component {
state = { horzontal: false, gap: 100 };
render() {
return (
<React.Fragment>
<button
onClick={() => {
this.setState({
horzontal: !this.state.horzontal,
gap: this.state.horzontal ? 100 : 220
});
}}
>
换
</button>
<List
horizontal={this.state.horzontal}
data={Data}
gap={this.state.gap}
renderItem={(handle, data) => (
<div className="props-draggers" {...handle()}>
{data.name}
</div>
)}
/>
</React.Fragment>
);
}
}
ReactDOM.render(<C />, document.getElementById('root'));
registerServiceWorker();