mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-21 15:38:59 +03:00
virtualContext: fix useVirtualResizeProp
This commit is contained in:
parent
1a01e58b7b
commit
f80ca5a3da
@ -7,6 +7,7 @@ import React, {
|
||||
useEffect,
|
||||
} from "react";
|
||||
import usePreviousValue from "./usePreviousValue";
|
||||
import {Primitive} from "~/types";
|
||||
|
||||
export interface VirtualContextProps {
|
||||
save: () => void;
|
||||
@ -49,7 +50,7 @@ export function useVirtualResizeState(s: boolean) {
|
||||
return [state, setState] as const;
|
||||
}
|
||||
|
||||
export function useVirtualResizeProp<T>(prop: T) {
|
||||
export function useVirtualResizeProp(prop: Primitive) {
|
||||
const { save, restore } = useVirtual();
|
||||
const oldProp = usePreviousValue(prop)
|
||||
|
||||
@ -58,7 +59,7 @@ export function useVirtualResizeProp<T>(prop: T) {
|
||||
}
|
||||
|
||||
useLayoutEffect(() => {
|
||||
restore();
|
||||
requestAnimationFrame(restore);
|
||||
}, [prop]);
|
||||
|
||||
|
||||
|
@ -18,7 +18,7 @@ import { GroupLink } from "~/views/components/GroupLink";
|
||||
import GlobalApi from "~/logic/api/global";
|
||||
import { getModuleIcon } from "~/logic/lib/util";
|
||||
import useMetadataState from "~/logic/state/metadata";
|
||||
import { Association, resourceFromPath } from "@urbit/api";
|
||||
import { Association, resourceFromPath, GraphNode } from "@urbit/api";
|
||||
import { Link } from "react-router-dom";
|
||||
import useGraphState from "~/logic/state/graph";
|
||||
import { GraphNodeContent } from "../notifications/graph";
|
||||
@ -51,7 +51,7 @@ function GraphPermalink(
|
||||
const { full = false, showOurContact, pending, link, graph, group, index, api, transcluded } = props;
|
||||
const { ship, name } = resourceFromPath(graph);
|
||||
const node = useGraphState(
|
||||
useCallback((s) => s.looseNodes?.[`${ship.slice(1)}/${name}`]?.[index], [
|
||||
useCallback((s) => s.looseNodes?.[`${ship.slice(1)}/${name}`]?.[index] as GraphNode, [
|
||||
graph,
|
||||
index,
|
||||
])
|
||||
@ -63,7 +63,7 @@ function GraphPermalink(
|
||||
])
|
||||
);
|
||||
|
||||
useVirtualResizeProp(node)
|
||||
useVirtualResizeProp(!!node)
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
if (pending || !index) {
|
||||
|
Loading…
Reference in New Issue
Block a user