Carlos P. Jimeno
jimenocontact@gmail.com
Jimeno0
Carlos P. Jimeno
@Jimeno0
React
@Jimeno0
@Jimeno0
@Jimeno0
@Jimeno0
<!DOCTYPE html>
<html lang="en">
<title>Test React</title>
<!-- Load React API -->
<script src= "https://unpkg.com/react@16/umd/react.production.min.js"></script>
<!-- Load React DOM-->
<script src= "https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
<!-- Load Babel Compiler -->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<body>
<div id="id"/>
<script type="text/babel">
ReactDOM.render(
<h1>Hello React!</h1>,
document.getElementById('id')
)
</script>
</body>
</html>
@Jimeno0
Capitalized JSX for components
props === attrs
ClassName as class
@Jimeno0
XML/HTML-like syntax used by React that extends ECMAScript
@Jimeno0
$ npx create-react-app my-app
$ cd my-app
$ npm start
@Jimeno0
@Jimeno0
Start with the boilerplate project
@Jimeno0
@Jimeno0
@Jimeno0
Presentation vs Logic
F.K.A
@Jimeno0
@Jimeno0
@Jimeno0
@Jimeno0
The new patterns
Funcions "hook into" state & lifecycle from function components
@Jimeno0
@Jimeno0
💥
@Jimeno0
@Jimeno0
Scaffolding
Complex logic mixed in components
Reusable code
Class components misunderstandings
❌
♻
🍱
🤓
@Jimeno0
Declare in the top level
❌
Dont use in Class Components
❌
@Jimeno0
(With clean code)
useState()
@Jimeno0
@Jimeno0
Try to refactor the toogle component
useEffect()
@Jimeno0
@Jimeno0
Refactor of our parallax web
@Jimeno0
@Jimeno0
1. Create a movies fakeAPI (bonus: use express)
2. render all movies
3. Add a filters Drawer in order to filter movies
@Jimeno0
json-server
db.json
Fake server with:
Axios
@Jimeno0
json-server
axios
integrate on useEffect
@Jimeno0
@Jimeno0
Working with inputs
Exercise: filter by year
@Jimeno0
@Jimeno0
@Jimeno0
export const ThemeContext = createContext({ value: {} })
const ThemeProvider = (props) => {
const [value, setValue] = useState('dark')
return (
<ThemeContext.Provider
value={{ value, setValue }}
>
{props.children}
</ThemeContext.Provider>
)
}
Create the context
@Jimeno0
<ThemeProvider>
<App />
</ThemeProvider>
provider
useContext()
@Jimeno0
@Jimeno0
Use context in our App
@Jimeno0
inLine
classNames
CSS in JS
@Jimeno0
<💅>
@Jimeno0
const Button = styled.button`
background: transparent;
border-radius: 3px;
border: 2px solid palevioletred;
color: palevioletred;
margin: 0 1em;
padding: 0.25em 1em;
`
@Jimeno0
Refactor our webApp to styled components
@Jimeno0
React router
react-router-dom
@Jimeno0
Routes, Links and Consumers
@Jimeno0
<BrowserRouter>
...
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
...
</BrowserRouter>
@Jimeno0
<Switch>
<Route path="/about">
<About />
</Route>
<Route path="/users">
<Users />
</Route>
<Route path="/">
<Home />
</Route>
</Switch>
@Jimeno0
heroku
@Jimeno0
1. Login to heroku
2. Connect our app with Github
3. build & start scripts
4. serve package