This file contains hidden or 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, useState } from 'react'; | |
import { useHistory, useLocation } from 'react-router-dom'; | |
/* | |
* The following hook makes use of this technique | |
* https://react.dev/reference/react/useState#storing-information-from-previous-renders | |
* thus cutting down the amount of re-renders to a minimum. | |
* Do not freak out by the lack of useEffects | |
* // 2024 Dimitris Karagiannis | |
* // Twitter: @MitchKarajohn |
This file contains hidden or 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
// Usecase: Say you have an endpoint `/clients` and you have created a custom | |
// hook, that wraps over a `useQuery` that has a fixed `queryKey` and `queryFn` | |
// (because it is supposed to only fetch data from the `/clients` endpoint) | |
// However you want to be able to pass a valid `useQuery` config object in order | |
// to customize its behaviour (except for passing a custom queryKey or queryFn) | |
// This is one way to do this. | |
// 2023 Dimitris Karagiannis | |
// Twitter: @MitchKarajohn | |
export function useSpecificButCustomizableQuery( |
This file contains hidden or 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
/* collapsed_stacked_inlines.js */ | |
/* Created in May 2009 by Hannes Rydén */ | |
/* Use, distribute and modify freely */ | |
// Original script | |
// https://djangosnippets.org/snippets/1492/ | |
// 2021 updates by Dimitris Karagiannis | |
// @MitchKarajohn |
This file contains hidden or 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 fileMachine = Machine( | |
{ | |
id: 'file', | |
initial: 'idle', | |
context: null, | |
states: { | |
idle: { | |
on: { | |
START: 'pending', | |
}, |
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) |
This file contains hidden or 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions | |
// - XState (all XState exports) |
This file contains hidden or 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
{"lastUpload":"2018-05-05T00:31:17.192Z","extensionVersion":"v2.9.2"} |