Skip to content

Commit

Permalink
#70 Memoize iframe url to avoid unexpected reload
Browse files Browse the repository at this point in the history
  • Loading branch information
wongchito committed Apr 28, 2024
1 parent 6d43883 commit ca317cb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/components/workspace/app-container.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useMemo } from 'react';
import { FRAME_ID_PREFIX, WorkspaceTab } from '../../util/constants';
import { Box } from '@chakra-ui/react';

Expand All @@ -10,9 +10,7 @@ interface AppContainerProps {
export default function AppContainer(props: AppContainerProps) {
const { tab, isActive } = props;

const [frameUrl] = useState(tab.url ?? '/' + tab.app + '/');

// setFrameUrl if tab.id is updated?
const frameUrl = useMemo(() => tab.url ?? '/' + tab.app + '/', [tab.url, tab.app]);

return (
<Box display={isActive ? 'block' : 'none'} flex={1}>
Expand Down

0 comments on commit ca317cb

Please sign in to comment.