storybook/docs/_snippets/storybook-addons-api-usestorybookstate.md
2024-06-13 17:53:08 +01:00

520 B

import React from 'react';

import { AddonPanel } from '@storybook/components';

import { useStorybookState } from '@storybook/manager-api';

export const Panel = () => {
  const state = useStorybookState();
  return (
    <AddonPanel {...props}>
      {state.viewMode !== 'docs' ? (
        <h2>Do something with the documentation</h2>
      ) : (
        <h2>Show the panel when viewing the story</h2>
      )}
    </AddonPanel>
  );
};