This file contains hidden or 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
| // Response da query acima | |
| { | |
| "data": { | |
| "people": { | |
| "name": "Luke Skywalker" | |
| } | |
| } | |
| } |
This file contains hidden or 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
| # Query que consulta um personagem com id 1 | |
| query { | |
| people(id: "1") { | |
| name | |
| } | |
| } |
This file contains hidden or 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
| type People { | |
| name: String, | |
| height: String, | |
| mass: String, | |
| hair_color: String, | |
| skin_color: String, | |
| eye_color: String, | |
| birth_year: String, | |
| gender: String, | |
| homeworld: String, |
This file contains hidden or 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' | |
| interface Props { | |
| counter: number | |
| } | |
| function Counter({ counter }: Props) { | |
| return <p>{counter}</p> | |
| } |
This file contains hidden or 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, { useEffect } from 'react' | |
| function WillUnmount() { | |
| useEffect(() => { | |
| console.log('Eu estou montado') | |
| return () => { | |
| console.log('Vou desmontar') | |
| } | |
| }, []) |
This file contains hidden or 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, { Component } from 'react' | |
| class WillUnmount extends Component { | |
| componentDidMount() { | |
| console.log('Eu estou montado') | |
| } | |
| componentWillUnmount() { | |
| console.log('Vou desmontar') | |
| } |
This file contains hidden or 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, { useEffect, useState } from 'react' | |
| function DidUpdate() { | |
| const [name, setName] = useState('') | |
| const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => setName(e.target.value) | |
| useEffect(() => { | |
| console.log('Eu estou montado ou sofri alteração') | |
| }, [name]) |
This file contains hidden or 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, { Component } from 'react' | |
| interface State { | |
| name: string | |
| } | |
| class DidUpdate extends Component<{}, State> { | |
| state = { | |
| name: '' | |
| } |
This file contains hidden or 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' | |
| interface Props { | |
| initialState: number, | |
| step: number | |
| } | |
| function useCounter({ initialState, step }: Props) { | |
| const [count, setCount] = useState(initialState) | |
| const increment = () => setCount(count + step) |
This file contains hidden or 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
| // componentDidMount com hooks | |
| import React, { useEffect } from 'react' | |
| function DidMount() { | |
| useEffect(() => console.log('Eu estou montado'), []) | |
| return <>content</> | |
| } | |
| export default DidMount |