Skip to content

Commit

Permalink
Se creo el proyecto
Browse files Browse the repository at this point in the history
  • Loading branch information
axelme28 committed Aug 25, 2021
1 parent a95c1d8 commit fe0b0d1
Show file tree
Hide file tree
Showing 16 changed files with 187 additions and 138 deletions.
26 changes: 2 additions & 24 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,12 @@
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.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/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<title>Hooks-App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
38 changes: 0 additions & 38 deletions src/App.css

This file was deleted.

25 changes: 0 additions & 25 deletions src/App.js

This file was deleted.

8 changes: 0 additions & 8 deletions src/App.test.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/HookApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react'

export const HookApp = () => {
return (
<>

</>
)
}
20 changes: 20 additions & 0 deletions src/components/01-UseState/CounterApp.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body{
padding: 7rem;
background-color: #34495E;
}

h1{
font-family: sans-serif;
color: azure;
display: flex;
justify-content: center;
}

button{
height: fit-content;
}

.buttons{
display: flex;
justify-content: space-around;
}
33 changes: 33 additions & 0 deletions src/components/01-UseState/CounterApp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react'
import './CounterApp.css'

export const CounterApp = () => {

const [state, setState] = useState({
counter1: 10,
counter2: 20,
counter3: 30,
counter4: 40
}
)

const {counter1,counter2} = state;


return (
<>
<h1>Counter1 {counter1} </h1>
<h1>Counter2 {counter2}</h1>
<button
className="btn btn-primary"
onClick = {() => {
setState({
...state,
counter1: counter1+1,

});
}}>+1
</button>
</>
)
}
21 changes: 21 additions & 0 deletions src/components/01-UseState/CounterWithCustomHook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { UseCounter } from '../hooks/UseCounter'
import './CounterApp.css'

export const CounterWithCustomHook = () => {

const {state,increment,decrement,reset} = UseCounter(0)

return (
<>
<h1>Counter with Hook: {state}</h1>
<hr/>
<div className = "buttons">
<button className="btn btn-primary" onClick = {() => {increment(2)}}> +1</button>
<button className = "btn btn-warning" onClick = {reset}>Reset</button>
<button className="btn btn-danger" onClick = {() => {decrement(2)}} > -1</button>
</div>

</>
)
}
14 changes: 14 additions & 0 deletions src/components/02-UseEfect/SimpleForm.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
h1{
font-family: sans-serif;
color: white;
}

.title{
padding: 3rem;
background-color: #1ABC9C;

}

.form{
margin: 2rem;
}
57 changes: 57 additions & 0 deletions src/components/02-UseEfect/SimpleForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react'
import { useEffect,useState } from 'react';
import './SimpleForm.css'
export const SimpleForm = () => {

const [form, setform] = useState({
name :'',
email:''
})

const {name,email} = form;

useEffect(() => {
console.log('hey!');
},[])

const handleInputChamge = ({target}) =>{
setform({
...form,
[target.name]:target.value
});
}


return (
< div className = "margin:1rem">
<div className = "title">
<h1>UseEffect</h1>
</div>
<form className= "form">
<div className = "form-grup mb-3">
<label className = "form-label">Name</label>
<input type = "text"
name = "name"
className = "form-control"
placeholder = "tu nombre"
autoComplete = "off"
value = {name}
onChange = {handleInputChamge}/>
</div>


<div className = "form-grup mb-3">
<label>Email</label>
<input type = "text"
name = "email"
className = "form-control"
placeholder = "[email protected]"
autoComplete = "off"
value = {email}
onChange = {handleInputChamge}/>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
)
}
24 changes: 24 additions & 0 deletions src/components/hooks/UseCounter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useState } from "react";

export const UseCounter = (initialState = 0) => {
const [state, setstate] = useState(initialState);

const increment = (factor = 1) =>{
setstate(state + factor)
}

const decrement = (factor = 1) => {
setstate(state - 1)
}

const reset = () =>{
setstate(initialState)
}

return {
state,
increment,
decrement,
reset
}
}
13 changes: 0 additions & 13 deletions src/index.css

This file was deleted.

18 changes: 7 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
//import { CounterApp } from './components/01-UseState/CounterApp';
//import { CounterWithCustomHook } from './components/01-UseState/CounterWithCustomHook';
import { SimpleForm } from './components/02-UseEfect/SimpleForm';
//import { HookApp } from './HookApp';


ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
<SimpleForm/>,
document.getElementById('root')
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
1 change: 0 additions & 1 deletion src/logo.svg

This file was deleted.

13 changes: 0 additions & 13 deletions src/reportWebVitals.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/setupTests.js

This file was deleted.

0 comments on commit fe0b0d1

Please sign in to comment.