-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
58 lines (54 loc) · 1.37 KB
/
App.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
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import useReducerWithLocalStorage from 'use-reducer-with-local-storage';
import reducer, { emptyState } from './store/reducer';
import './App.css';
import makeHandleOnChange from './makeHandleOnChange';
function App() {
const [{ bio, name, url }, dispatch] = useReducerWithLocalStorage({
initializerArg: emptyState,
key: 'REACT_APP_STATE',
reducer
});
const handleOnChange = makeHandleOnChange({ dispatch });
return (
<div className="App">
<h1 className="App__h1">Public profile</h1>
<form className="App__form">
<input
className="App__input"
name="name"
onChange={handleOnChange}
placeholder="Name"
type="text"
value={name}
/>
<textarea
className="App__textarea"
cols="40"
name="bio"
onChange={handleOnChange}
placeholder="Bio"
rows="10"
value={bio}
/>
<input
className="App__input"
name="url"
onChange={handleOnChange}
placeholder="URL"
type="text"
value={url}
/>
<button
className="App__button"
name="clear"
onClick={handleOnChange}
type="button"
>
Clear
</button>
</form>
</div>
);
}
export default App;