This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub Action that will run prettier on the whole repo and commit the changes to the PR. | |
name: Prettier | |
on: | |
pull_request: | |
branches: [main] | |
jobs: | |
prettier: | |
runs-on: ubuntu-latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Component(){ | |
const [searchTerm, setSearchTerm] = React.useState("") | |
const filterWithGoodName = React.useMemo(() => { | |
return searchTerm.filter(.....) | |
}, [searchTerm]) | |
return ( | |
<input onSearch={setSearchTerm}/> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildSearchGroups(term, searchFields) { | |
const searchGroups = []; | |
if (term) { | |
const searchTermList = term.trim().split(' '); | |
searchTermList.forEach(searchTerm => { | |
const searchGroup = { m: 'or' }; | |
searchFields.forEach(field => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HOC is a function with a component that return a new component. | |
//geolocation.js | |
function withGeolocation(Component) { | |
function Geolocation() { | |
const [latitude, setLatitude] = React.useState(0); | |
const [longitude, setLongitude] = React.useState(0); | |
React.useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using hooks with useEffect like this : | |
useState(async ()=>{ | |
const response = await fetch(url); | |
const json = await response.json(); | |
setData(json); | |
} | |
- with Classes using compenentDidMount or willMount : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using hooks with useEffect like this : | |
useState(async ()=>{ | |
const response = await fetch(url); | |
const json = await response.json(); | |
setData(json); | |
} | |
- with Classes using compenentDidMount or willMount : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Propinas</title> | |
<link rel="stylesheet" type="text/css" href="css/normalize.css" /> | |
<link rel="stylesheet" type="text/css" href="css/styles.css" /> | |
</head> | |
<body> | |
<div id="container"> |