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
import React, { useState, useEffect, memo } from "react"; | |
import useCount from "../hooks/useCount"; | |
import "./styles.css"; | |
function Hooks() { | |
const [name, setName] = useState("Zagatti"); | |
const { count, increment, decrement } = useCount(); |
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
import { useState } from "react"; | |
export default function useCount() { | |
const [count, setCount] = useState(0); | |
function increment() { | |
setCount(state => state + 1); | |
} | |
function decrement() { |
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
import React, { useState, useEffect, memo } from "react"; | |
import "./styles.css"; | |
function Hooks() { | |
const [name, setName] = useState("Zagatti"); | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
document.title = `${name}'s counter`; |
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
import React, { PureComponent } from "react"; | |
import "./styles.css"; | |
export default class Class extends PureComponent { | |
state = { | |
name: "Zagatti", | |
count: 0 | |
}; |
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
import React, { PureComponent } from "react"; | |
import "./styles.css"; | |
export default class Class extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { | |
name: "Zagatti", |
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
{ | |
"workbench.colorTheme": "Dracula", | |
"workbench.iconTheme": "material-icon-theme", | |
"editor.fontSize": 12, | |
"editor.fontFamily": "Fira Code", | |
"editor.fontLigatures": true, | |
"eslint.validate": [ | |
"javascript", | |
"javascriptreact", | |
"typescript", |
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
import React, { useState, useEffect } from "react"; | |
function App() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
setInterval(() => setCount(state => state + 1), 1000); | |
}, []); | |
return ( |
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
import React, { useState, useEffect } from "react"; | |
function App() { | |
const [count, setCount] = useState(0); | |
useEffect(() => { | |
const interval = setInterval(() => setCount(count + 1), 1000); | |
return () => { | |
clearInterval(interval) |
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
import React, { useState } from "react"; | |
import Person from "./components/Person"; | |
function App() { | |
const [name, setName] = useState(''); | |
return ( | |
<div> | |
<input type="text" value={name} onChange={e => setName(e.target.value)} /> |
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
import React from "react"; | |
import Person from "./components/Person"; | |
function App() { | |
return ( | |
<div> | |
<Person name="Solaire of Astora" /> | |
<Person name="Andre of Astora" /> | |
<Person name="Sigmeyer of Catarina" /> |