From db4a119ed7fe6aca5b4c2c2183fbc9fb6b56ad31 Mon Sep 17 00:00:00 2001 From: Catharina Mesquita Date: Sat, 4 Apr 2020 11:47:39 -0300 Subject: [PATCH 01/11] Criando o projeto --- package.json | 2 +- src/components/ComponentList/index.js | 19 +++++++++++++------ src/store/reducer/example-reducer.js | 8 ++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 27e33f4..70b0398 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "templete-redux", + "name": "notes-app", "version": "0.1.0", "private": true, "dependencies": { diff --git a/src/components/ComponentList/index.js b/src/components/ComponentList/index.js index c3e6885..8a4bbd7 100644 --- a/src/components/ComponentList/index.js +++ b/src/components/ComponentList/index.js @@ -1,26 +1,33 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { Types } from '../../store/reducer/example-reducer'; export default function ComponentList() { const qty = 20 + const [text, setText] = useState('') const list = useSelector( - state => state.exampleReducer.data.slice(0, qty) + state => state.exampleReducer.data.slice(0, qty) , [qty]); const dispatch = useDispatch(); - function add(){ - dispatch({ type: Types.ADD, title: 'GrafQL'}) + function add() { + dispatch({ type: Types.ADD, title: text }) } return ( <> +