mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
support deprecated API unattached
This commit is contained in:
parent
0984503694
commit
d23bed8074
@ -128,10 +128,17 @@ export const Canvas: FC<CanvasProps & DeprecatedCanvasProps> = (props) => {
|
||||
const docsContext = useContext(DocsContext);
|
||||
const sourceContext = useContext(SourceContext);
|
||||
const { children, of, source } = props;
|
||||
const sourceProps = useSourceProps({ ...source, of }, docsContext, sourceContext);
|
||||
const { isLoading, previewProps } = useDeprecatedPreviewProps(props, docsContext, sourceContext);
|
||||
|
||||
const { story } = useOf(of || 'story', ['story']);
|
||||
let story;
|
||||
let sourceProps;
|
||||
try {
|
||||
({ story } = useOf(of || 'story', ['story']));
|
||||
sourceProps = useSourceProps({ ...source, of }, docsContext, sourceContext);
|
||||
} catch (error) {
|
||||
if (!children) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
if (props.withSource) {
|
||||
deprecate(dedent`Setting source state with \`withSource\` is deprecated, please use \`sourceState\` with 'hidden', 'shown' or 'none' instead.
|
||||
|
@ -46,6 +46,10 @@ const expectAmountOfStoriesInSource =
|
||||
|
||||
export const BasicStoryChild: Story = {};
|
||||
|
||||
export const BasicStoryChildUnattached: Story = {
|
||||
parameters: { attached: false },
|
||||
};
|
||||
|
||||
export const WithSourceOpen: Story = {
|
||||
args: {
|
||||
withSource: SourceState.OPEN,
|
||||
|
Loading…
x
Reference in New Issue
Block a user