Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
nametake committed Aug 6, 2023
1 parent ae3dfdb commit b6cb508
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/app/pages/Reducer.tsx
Expand Up @@ -8,13 +8,13 @@ type DataType = {
type State = {
data: DataType[];
removeTargets: string[];
inputValue: string;
addInput: string;
};

const initState: State = {
data: [],
removeTargets: [],
inputValue: '',
addInput: '',
};

type Action =
Expand Down Expand Up @@ -44,16 +44,16 @@ const reducer = (prev: State, action: Action): State => {
case 'EDIT_ADD_INPUT':
return {
...prev,
inputValue: action.value,
addInput: action.value,
};
case 'CLICK_ADD_BUTTON':
return {
...prev,
data: [
...prev.data,
{ id: Date.now().toString(), text: prev.inputValue },
{ id: Date.now().toString(), text: prev.addInput },
],
inputValue: '',
addInput: '',
};
default: {
const exhaustiveCheck: never = action;
Expand Down Expand Up @@ -113,7 +113,7 @@ export const Reducer = function Reducer(): JSX.Element {
</div>
))}
<div>
<input value={state.inputValue} onChange={handleAddInput} />
<input value={state.addInput} onChange={handleAddInput} />
<button type="button" onClick={handleAddButton}>
add
</button>
Expand Down

0 comments on commit b6cb508

Please sign in to comment.