Merge remote-tracking branch 'origin/main' into terry-wallet-login
This commit is contained in:
@@ -45,7 +45,15 @@ export function Home() {
|
||||
const { t, lang } = useI18n();
|
||||
const lp = useLocalizedPath();
|
||||
const { hash } = useLocation();
|
||||
const [cats, setCats] = useState<Category[]>([]);
|
||||
// Seed from cache on the first render so the categories (and their icons)
|
||||
// are present immediately when navigating back to the home page, instead of
|
||||
// flashing empty for a frame before the effect re-applies the cached data.
|
||||
const [cats, setCats] = useState<Category[]>(() => {
|
||||
const cached = readJSONCache<Category[]>(
|
||||
`/api/categories?lang=${encodeURIComponent(langQuery(lang))}`,
|
||||
);
|
||||
return cached ? itemsOrEmpty(cached) : [];
|
||||
});
|
||||
const [rec, setRec] = useState<PostBackedResource[]>([]);
|
||||
const [latestPosts, setLatestPosts] = useState<Post[]>([]);
|
||||
const [popular, setPopular] = useState<PostBackedResource[]>([]);
|
||||
|
||||
Reference in New Issue
Block a user