Skip to content

Instantly share code, notes, and snippets.

View gsasouza's full-sized avatar
🔥
Working on bleeding edge

Gabriel Souza gsasouza

🔥
Working on bleeding edge
View GitHub Profile
@gsasouza
gsasouza / machine.js
Last active October 4, 2021 20:13
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const StyledGenericComponent = styled.div``;
type GenericProps<T> = {
as?: React.FC<T>
//...otherProps
}
const GenericComponent = <T>({ as, ...props }: Props<T> & T) => {
// some logic
return <StyledGenericComponent as={as} {...props}/>
import * as React from 'react';
import { useLocation } from 'react-router-dom';
import { graphql, usePreloadedQuery, useEnvironment } from 'react-relay/hooks';
const Comp1 = React.lazy(() => import('./Comp1'));
const Comp2 = React.lazy(() => import('./Comp2'));
const Comp3 = React.lazy(() => import('./Comp3'));
const Query = graphql`
query RootQuery(
// ---- routes.ts ---
import * as React from 'react';
import { prepareQuery } from '../../relay';
export default [
{
path: path => `${path}Home`,
component: React.lazy(() => import('./Home')),
prepare: () => {
@gsasouza
gsasouza / useAuth.js
Created March 2, 2020 21:25
Relay hook to handle authenticantion
import { ROOT_ID } from 'relay-runtime';
import { useRelayEnvironment } from 'react-relay/hooks';
import { useLocation, useHistory } from 'react-router-dom';
import { commitLocalUpdate } from 'react-relay'
import { useMutation } from 'relay-hooks/lib';
import { AuthUserMutation } from 'mutations/AuthUserMutation';
export const TOKEN_KEY = 'KEY';
const theme = {
name: 'Credihome' //Nome da empresa
primaryColor: '#ffff' // cor primária
secondaryColor: '#ffff' // cor secundária
logo: 'https://...' // link pro image do logo
logoCompact: 'https://...' // link pro image do compacto
}
@gsasouza
gsasouza / .js
Created December 15, 2019 18:46
const name = 'Gabriel Santos Souza';
const firstName = name.split(' ')[0];
const secondName = name.split(' ')[1];
console.log(firstName.length + secondName.length);
@gsasouza
gsasouza / .js
Created December 11, 2019 23:12
const { user } = tweet;
const { password, ...userWithoutPassword } = user;
const newTweet = { ...tweet, user: userWithoutPassword };
const Login = withFormik<{}, FormValues>({
mapPropsToValues: () => ({
password: '',
email: '',
remember: true
}),
validationSchema: Yup.object().shape({
email: Yup.string().required('Usuário é obrigatório'),
password: Yup.string().required('Senha é obrigatório'),
}),
const Container = styled.div`
.classe-1 {}
.classe-2 {}
`;
export default function App() {
return (
<Container>
<div className="classe-1"/>
<div className="classe-2"/>
</Container>