Skip to content

Commit

Permalink
useContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Misael-GC committed Nov 2, 2023
1 parent cf37158 commit 7dd42c2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 30 deletions.
8 changes: 4 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="%PUBLIC_URL%/mgc.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#97ca3f" />
<meta
name="description"
content="Web site created using create-react-app"
name="Aplicación de Taeras por hacer"
content="Web site created using create-react-app por Misael Gomez Cuautle"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/react192.png" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/mgc.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
Expand Down
Binary file added public/mgc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 14 additions & 18 deletions src/App/AppUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@ import { TodoGraphicLoading } from "../TodoGraphicLoading";
import { TodoContext } from "../TodoContext";

function AppUI() {
const {
loading,
error,
completedTodos,
totalTodos,
searchedTodos,
completeTodo,
deleteTodo,
showSearch,
showCounter,
showGraphic,
} = React.useContext(TodoContext);
return (
<>
<Nadvar />
<TodoContext.Consumer>
{({
loading,
error,
completedTodos,
totalTodos,
motivationalPhrase,
searchValue,
setSearchValue,
searchedTodos,
completeTodo,
deleteTodo,
showSearch,
showCounter,
showGraphic,
}) => (

<div className="SuperiorContainerAll">
{loading && (
<>
Expand Down Expand Up @@ -82,8 +79,7 @@ function AppUI() {

{/* Arreglar los estilos */}
</div>
)}
</TodoContext.Consumer>

<CreateTodoButton />
<Footer />
</>
Expand Down
2 changes: 1 addition & 1 deletion src/TodoContext/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function TodoProvider({ children }) {
error,
completedTodos,
totalTodos,
motivationalPhrase,
motivationalPhrase,
searchValue,
setSearchValue,
searchedTodos,
Expand Down
9 changes: 6 additions & 3 deletions src/TodoCounter/index.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import "./TodoCounter.css"
import { TodoContext } from '../TodoContext';

function TodoCounter({ total, completed, motivationalPhrase }){
function TodoCounter(){

const { totalTodos, completedTodos, motivationalPhrase } = React.useContext(TodoContext);

return(
<h1 className="TodoCounter">
Has completado <span>{completed} </span>
de <span>{total}</span> TODOs
Has completado <span>{completedTodos} </span>
de <span>{totalTodos}</span> TODOs
<p>{motivationalPhrase}</p>
</h1>
);
Expand Down
10 changes: 6 additions & 4 deletions src/TodoSearch/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import { AiOutlineSearch } from "react-icons/ai";
import './TodoSearch.css';
import { TodoContext } from '../TodoContext';

function TodoSearch({
searchValue,
setSearchValue,
}){
function TodoSearch(){
const {
searchValue,
setSearchValue,
} = React.useContext(TodoContext);

return(
<div className="container-sm mb-5 ">
Expand Down

0 comments on commit 7dd42c2

Please sign in to comment.