Skip to content

Commit

Permalink
fix: update context on storyid change
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Aug 1, 2020
1 parent e6ae20d commit 05b17b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions core/store/src/state/context/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export const useStory = (props: StoryInputProps): Story | undefined => {
setStory(updatedStory);
}
};
setStory(storyId ? store.stories[storyId] : undefined);
store.addObserver(onObserver);
return () => store.removeObserver(onObserver);
}, [store, storyId]);
Expand Down
7 changes: 2 additions & 5 deletions examples/starter/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@ import { GetStaticProps } from 'next';
import { DocType, defDocType } from '@component-controls/core';
import { DocPage } from '@component-controls/app';
import { Layout, store, getIndexPage } from '@component-controls/nextjs-plugin';

interface PageListProps {
type: DocType;
docId?: string;
}

const HomePage: FC<PageListProps> = ({ type = defDocType, docId }) => {
return (
<Layout docId={docId}>
<DocPage type={type} />
</Layout>
);
};

export const getStaticProps: GetStaticProps = async () => {
const { docId = null, type = null } = getIndexPage(store);
const homePage = getIndexPage(store);
const { docId = null, type = null } = homePage;
return { props: { docId, type } };
};

export default HomePage;

0 comments on commit 05b17b7

Please sign in to comment.