Skip to main content

Type Alias: StoryContentFn<TProps>

StoryContentFn<TProps> = DefineFn<StoryHelpers, StoryContentItems, TProps>

Defined in: packages/core/src/passages/story/types.ts:1017

Content callback accepted by defineStory.

Receives the StoryHelpers toolbox first and the display props second.

Type Parameters

TProps

TProps extends InitVarsType = EmptyObject

Type of props passed to story.display()

Remarks

Unlike StoryContent, this is a generic alias rather than a generic function type, so authors can annotate their props and have them checked:

const content: StoryContentFn<{ playerName: string }> = (h, props) => [
h.text(`Hello, ${props.playerName}!`)
];

Example

const content: StoryContentFn = (h) => [
h.header('Welcome'),
h.text('Your adventure begins...'),
h.actions([{ content: 'Start', action: h.jump('chapter-1') }])
];