Skip to content

Instantly share code, notes, and snippets.

View renerbaffa's full-sized avatar

Rener Baffa da Silva renerbaffa

View GitHub Profile
@renerbaffa
renerbaffa / extends.ts
Last active September 4, 2023 15:24
What to extend in order to support spread props with typescript
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
icon: React.ReactNode
// ...other props
}
interface CustomDivProps extends React.HTMLAttributes<HTMLDivElement> {
content: string
// ...other props
}
const TIMEOUT = 3000
Machine({
id: 'fetchMachine',
initial: 'idle',
context: {
response: null,
error: null,
},
states: {
@renerbaffa
renerbaffa / machine.js
Last active April 29, 2020 18:13
Generated by XState Viz: https://xstate.js.org/viz
const { cancel } = actions
function saveChanges() {
console.log('here')
}
const fetchMachine = Machine({
id: 'selectionMachine',
type: 'parallel',
states: {
@renerbaffa
renerbaffa / machine.js
Last active April 29, 2020 08:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@renerbaffa
renerbaffa / machine.js
Last active April 29, 2020 08:32
Generated by XState Viz: https://xstate.js.org/viz
// 1
function fetchUsers() {}
const fetchMachine = Machine({
id: 'multi-admin',
initial: 'fetch-users',
context: {
allUsers: [],
selected: [],
function fetchData() {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject();
}, 1000);
});
}
const goatMachine = Machine({
initial: "idle",
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
const priceCalculatorMachine = Machine({
id: 'priceCalculatorMachine',
initial: 'active',
context: {
flag: false,
},
states: {
active: {
on: {
TOGGLE: {