diff --git a/core/store/src/state/context/story.tsx b/core/store/src/state/context/story.tsx index d3059a063..705961f8f 100644 --- a/core/store/src/state/context/story.tsx +++ b/core/store/src/state/context/story.tsx @@ -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]); diff --git a/examples/starter/pages/index.tsx b/examples/starter/pages/index.tsx index fb6ec799a..d8692a621 100644 --- a/examples/starter/pages/index.tsx +++ b/examples/starter/pages/index.tsx @@ -3,12 +3,10 @@ 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 = ({ type = defDocType, docId }) => { return ( @@ -16,10 +14,9 @@ const HomePage: FC = ({ type = defDocType, docId }) => { ); }; - 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;