MCPcopy Create free account
hub / github.com/Make-md/makemd / PathStickerContainer

Function PathStickerContainer

src/shared/components/PathSticker.tsx:143–181  ·  view source on GitHub ↗
(props: {
  superstate: Superstate;
  path: string;
})

Source from the content-addressed store, hash-verified

141};
142
143export const PathStickerContainer = (props: {
144 superstate: Superstate;
145 path: string;
146}) => {
147 const [cache, setCache] = useState<PathState>(null);
148 const reloadCache = () => {
149 setCache(props.superstate.pathsIndex.get(props.path));
150 };
151 const reloadIcon = (payload: { path: string }) => {
152 if (payload.path == props.path) {
153 reloadCache();
154 }
155 };
156
157 useEffect(() => {
158 reloadCache();
159 props.superstate.eventsDispatcher.addListener(
160 "pathStateUpdated",
161 reloadIcon
162 );
163
164 return () => {
165 props.superstate.eventsDispatcher.removeListener(
166 "pathStateUpdated",
167 reloadIcon
168 );
169 };
170 }, [props.path]);
171
172 return cache ? (
173 <PathStickerView
174 superstate={props.superstate}
175 pathState={cache}
176 editable={true}
177 />
178 ) : (
179 <></>
180 );
181};

Callers

nothing calls this directly

Calls 3

reloadCacheFunction · 0.70
addListenerMethod · 0.45
removeListenerMethod · 0.45

Tested by

no test coverage detected