- learn how to build JSX basic components
- learn component props
- learn how to manage state
- learn basic hooks (useState and useEffect)
- learn how to fetch Rest API's (Axios, SWR)
- learn how to use routes with React Router DOM
- learn how to manage global state (Context API, Redux, MobX)
- learn how to make unit tests with Jest
- learn how to use GraphQL (Apollo, Relay)
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, { createContext, useState, useEffect } from 'react' | |
import uuid from 'uuid' | |
export const TaskListContext = createContext() | |
const TaskListContextProvider = props => { | |
const initialState = JSON.parse(localStorage.getItem('tasks')) || [] | |
const [tasks, setTasks] = useState(initialState) | |
const [filteredTasks, setFilteredTasks] = useState(initialState) |
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
<GLView | |
style={{ flex: 1 }} | |
onContextCreate={async (gl) => { | |
// GL Parameter disruption | |
const { drawingBufferWidth: width, drawingBufferHeight: height } = gl; | |
// Renderer declaration and set properties | |
const renderer = new Renderer({ gl }); | |
renderer.setSize(width, height); | |
renderer.setClearColor("#fff"); |
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 { Snackbar } from '@material-ui/core'; | |
import { Alert, Color } from '@material-ui/lab'; | |
import React, { createContext, useContext } from 'react'; | |
type SnackBarContextActions = { | |
showSnackBar: (text: string, typeColor: Color) => void; | |
}; | |
const SnackBarContext = createContext({} as SnackBarContextActions); |
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 { useEffect, RefObject } from 'react'; | |
export function useOutsideClick(ref: RefObject<HTMLInputElement>, callback) { | |
function handleClick(e: MouseEvent) { | |
if (ref.current === e.target) { | |
callback(); | |
} | |
} | |
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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.7.0 <0.9.0; | |
contract GadosCoin { | |
mapping(address => uint) public balances; | |
mapping(address => mapping(address => uint)) public allowance; | |
uint public totalSupply = 1000 * 10 ** 18; | |
string public name = "GadosCoin"; | |
string public symbol = "GadosCoin"; | |
uint public decimals = 18; |
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
useClickOutside({ | |
isOpen, | |
ref: containerRef, | |
onRequestClose: () => setIsOpen(false), | |
}) |
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 { | |
createContext, | |
ReactNode, | |
useContext, | |
useEffect, | |
useState, | |
} from 'react' | |
import { setCookie, parseCookies, destroyCookie } from 'nookies' | |
import Router from 'next/router' |
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
// outside component (after imports) | |
const useAuth = jest.spyOn(require('contexts/AuthContext'), 'useAuth') | |
const user = { | |
user: { | |
name: 'Roberto Firmino', | |
}, | |
} | |
// inside describe | |
useAuth.mockReturnValue(user) |
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 '__mocks__/broadcast' | |
import { ReactChildren, ReactChild } from 'react' | |
import { render } from '@testing-library/react' | |
import { GlobalStyles } from 'styles' | |
import { ToastContainer } from 'components/Toast' | |
import { AuthProvider } from 'contexts/AuthContext' | |
import { SidebarProvider } from 'contexts/SidebarContext' |
OlderNewer