last update: Dec 4, 2020
- macOS >= 10.14 (Mojave); tested with 10.15 (Catalina)
- homebrew properly installed
last update: Dec 4, 2020
// If the user has been on the page for over 12 hours, the next link | |
// click will do a full page transition to get new code | |
import React from "react"; | |
import { BrowserRouter, useLocation } from "react-router-dom"; | |
let hour = 3600000; | |
export default function StaleAppRouter(props) { | |
let [isStale, setIsStale] = useState(false); |
Made this example to show how to use Next.js router for a 100% SPA (no JS server) app.
You use Next.js router like normally, but don't define getStaticProps
and such. Instead you do client-only fetching with swr
, react-query
, or similar methods.
You can generate HTML fallback for the page if there's something meaningful to show before you "know" the params. (Remember, HTML is static, so it can't respond to dynamic query. But it can be different per route.)
Don't like Next? Here's how to do the same in Gatsby.
import React from "react"; | |
import { | |
SafeAreaView, | |
ScrollView, | |
View, | |
Image, | |
StyleSheet, | |
Text, | |
useWindowDimensions, | |
ImageSourcePropType, |
import axios from 'axios' | |
import { useOptimisticMutation } from "./useOptimisticMutation.ts" | |
type Response = boolean | |
type Error = unknown | |
type MutationVariables = {itemId: string} | |
type Items = {id: string; name: string}[] | |
type Likes = {itemId: string}[] | |
type History = {type: string}[] |