-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
111 lines (100 loc) · 1.76 KB
/
index.tsx
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { createStore } from './src'
const rows = [
{
name: "nax",
email: "nax@gamil.com",
age: 10
},
{
name: "nax",
email: "nax@gamil.com",
age: 10
},
{
name: "nax",
email: "nax1@gamil.com",
age: 3
},
{
name: "nax",
email: "nax1@gamil.com",
age: 4
},
{
name: "najrul",
email: "najrul@gamil.com",
age: 30
},
{
name: "nax1",
email: "nax1@gamil.com",
age: 40
}
]
type Row = {
name: string;
email: string;
age: number;
}
const store = createStore<Row, {}>()
store.createMany(rows)
store.create({
name: "Naxrul",
email: "naxrul@gmail.com",
age: 20
})
function A() {
const [email, setEmail] = React.useState("nax@gamil.com")
const all = store.find({
email: {
startWith: "nax1"
}
})
return (
<div>
{all.map((item, idx: any) => {
return (
<li key={idx}>{item.email} - {item.name}</li>
)
})}
<button
onClick={() => {
setEmail("nax1@gamil.com")
}}
>Set Email</button>
</div>
)
}
const App = () => {
return (
<div>
<A />
<button
onClick={() => {
store.create({
name: Math.random().toString(),
email: "",
age: 20
})
}}
>Add+</button>
<button
onClick={() => {
store.create({
name: Math.random().toString(),
email: "",
age: 20
})
}}
>View</button>
<button
onClick={() => {
store.delete({ name: "nax" })
}}
>Delete</button>
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));