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 Transition from "react-transition-group/Transition"; | |
const duration = 300; | |
const Accordion = ({ in: inProp, children }) => { | |
const childrenType = typeof children.type; | |
if (childrenType === "undefined" || childrenType === "symbol") { | |
throw new Error( |
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
const mockData = require("./mock-data.json"); | |
const resolvers = { | |
Query: { | |
courses: (parent, args, context) => { | |
let edges = mockData; | |
let first = args.first; | |
let after = args.after; | |
let before = args.before; |
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
const fs = require('fs'); | |
const cp = require('child_process'); | |
const testFolder = './src'; | |
function getFiles(dir, files_ = []) { | |
const files = fs.readdirSync(dir); | |
Object.values(files).forEach((fileName) => { | |
const name = `${dir}/${fileName}`; |
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
const userTiming = () => (next) => (action) => { | |
if (performance.mark === undefined) return next(action); | |
performance.mark(`${action.type}_start`); | |
const result = next(action); | |
performance.mark(`${action.type}_end`); | |
performance.measure( | |
`${action.type}`, | |
`${action.type}_start`, | |
`${action.type}_end`, | |
); |
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
// ts 3.x | |
// https://stackoverflow.com/questions/54129289/typescript-call-a-member-of-an-object-with-arguments | |
let fns = { | |
set: (foo: string, bar: string) => { | |
return { foo, bar }; | |
} | |
}; | |
function callMethodWithArgs< | |
FnsObj extends { [key in MethodKey]: (...args: any[]) => any }, |
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
const connect = jest.fn((mapStateToProps) => { | |
const React = require.requireActual('react'); | |
const { rootReducer } = require.requireActual('../domains/root.reducer'); | |
const state = rootReducer({}, { type: '__jest-mock-react-redux__' }); | |
const fromConnectProps = mapStateToProps(state); | |
return jest.fn(Component => { | |
function Wrapper(props: any) { | |
const finalProps = { ...props, ...fromConnectProps }; |
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
const React = require('react'); | |
const ReactDOM = require('react-dom/server'); | |
const { renderStatic } = require('glamor/server'); | |
const http = require('http'); | |
const Component = require('....'); | |
const props = {} | |
const yolo = React.createElement(Component, props); |
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
// @flow | |
import * as React from "react"; | |
import { render } from "react-dom"; | |
type Circle = { type: "Circle" }; | |
type Cross = { type: "Cross" }; | |
type Empty = { type: "Empty" }; | |
type CellType = Circle | Cross | Empty; |
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
// algumas referências a elementos DOM | |
const input = document.querySelector('.js-input'); | |
const p1 = document.querySelector('.js-p1'); | |
const p2 = document.querySelector('.js-p2'); | |
const p3 = document.querySelector('.js-p3'); | |
// algumas ações para adicionar ao array de observadores | |
const updateP1 = text => p1.textContent = text; | |
const updateP2 = text => p2.textContent = text; | |
const updateP3 = text => p3.textContent = text; |
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
// definimos a classe | |
class Observable { | |
// cada instância da classe Observer | |
// começa com um array vazio de observadores/observers | |
// que reagem a uma mudança de estado | |
constructor() { | |
this.observers = []; | |
} | |
// adicione a capacidade de inscrever um novo objeto / Elemento DOM |