Skip to content

Instantly share code, notes, and snippets.

View leandrojo's full-sized avatar
🎯
Focusing

Leandro Araújo leandrojo

🎯
Focusing
  • São Paulo, Brasil
View GitHub Profile
import { init, RematchRootState } from '@rematch/core';
import createPersistPlugin from '@rematch/persist';
import * as models from './models';
const persist = createPersistPlugin({
whitelist: [],
});
const store = init({
function translate(document: any) {
if (typeof document !== 'object') return {};
return ({ raw, ...dictionary }: { raw: string[] }) => {
if (Array.isArray(document)) {
// @ts-ignore
return document.map((v: {}) => translate(v)({ raw, ...dictionary }));
}
if (raw !== undefined) {
/* eslint-disable react-hooks/exhaustive-deps */
import { useState } from 'react';
const useRequest = (request: Function = () => ({})) => {
const [data, setData] = useState(null);
const [isError, setIsError] = useState(false);
const [isLoading, setIsLoading] = useState(false);
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
const api = axios.create({
baseURL: '...',
});
export const mock = new MockAdapter(api, { delayResponse: 2000 });
export default api;
@leandrojo
leandrojo / custom-library.tsx
Created February 19, 2020 12:46
Trecho em Typescript 101
import React from 'react';
import TableCommunity from 'rc-table';
import { GetComponentProps } from 'rc-table/lib/interface';
interface Props {
columns: Array<{
[key: string]: any;
}>;
data: object[];
<Button type="primary">Primary Button</Button>
<Button type="success">Success Button</Button>
<Button type="warning">Warning Button</Button>
<Button type="danger">Danger Button</Button>
@leandrojo
leandrojo / action.js
Created November 14, 2018 19:08
Store/Register
/* @flow */
export const REGISTER_USER_REQUEST = "REGISTER_USER_REQUEST";
export const REGISTER_USER_SUCCESS = "REGISTER_USER_SUCCESS";
export const REGISTER_USER_FAILURE = "REGISTER_USER_FAILURE";
export function success(payload) {
return dispatch => {
dispatch({
type: REGISTER_USER_SUCCESS,
import React from "react";
import { Alert } from "react-native";
import { connect } from "react-redux";
import { compose, withHandlers, lifecycle } from "recompose";
import { css, withStyles, withRouter } from "../../common";
import Intro from "./Intro";
function componentDidMount() {
/**
* @param {*} obj - Objeto a ser rastreado.
* @param {*} key - Percurso a ser traçado.
*
* Exemplo:
* var obj = { a: { b: { c: 100 } } };
* get(obj, 'a.b.c'); // return 100.
*/
export default function Get(obj, key) {
data = [
{
description: 'Taxa de Juros',
value: '1.35',
},
{
description: 'Parcela',
value: '450.05',
},
];