Skip to content

Instantly share code, notes, and snippets.

import React from "react"
import { useLocation, useLoaderData, useFetcher } from "remix"
export default function useLoaderDataWithWindowFocusRefetching<LoaderData>() {
const loaderData = useLoaderData<LoaderData>()
const fetcher = useFetcher<LoaderData>()
const location = useLocation()
const pathnameRef = React.useRef(location.pathname)
React.useEffect(() => {
import React from "react"
import { useLocation, useNavigate } from "remix"
export default function useWindowFocusRefetching() {
const location = useLocation()
const navigate = useNavigate()
const pathnameRef = React.useRef(location.pathname)
React.useEffect(() => {
// add to your tailwind.config.js
const plugin = require("tailwindcss/plugin")
const radixPlugin = plugin(({ addVariant }) => {
const dataStates = [
"open",
"closed",
"active",
"inactive",
@hnordt
hnordt / machine.js
Last active August 20, 2020 16:02
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: "booking",
context: {
newsletterIndex: null,
placementId: null,
availabilityId: null,
reservationId: null
},
type: "parallel",
states: {
@hnordt
hnordt / machine.js
Last active August 19, 2020 02:26
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: "booking",
context: {
newsletterIndex: null,
placementId: null,
availabilityId: null,
},
type: "parallel",
states: {
booking: {
@hnordt
hnordt / machine.js
Last active August 18, 2020 00:28
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'booking',
context: {
placementId: null,
availabilityId: null
},
initial: 'step1',
states: {
step1: {
entry: "releaseReservation",
@hnordt
hnordt / machine.js
Last active May 30, 2020 15:01
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'app',
context: {},
initial: 'workouts',
states: {
workouts: {
on: {
NEW_WORKOUT: {
target: "newWorkout"
}
@hnordt
hnordt / machine.js
Created May 19, 2020 13:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@hnordt
hnordt / machine.js
Last active May 13, 2020 16:31
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'session',
initial: 'restoring',
states: {
restoring: {
initial: "loading",
states: {
loading: {
invoke: {
src: "restore",
@hnordt
hnordt / machine.js
Last active March 25, 2020 01:04
Generated by XState Viz: https://xstate.js.org/viz
Machine({
id: 'collections',
initial: 'fetching',
states: {
fetching: {
invoke: {
src: "fetchCollections",
onDone: "success",
onError: "failure"
}