Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs: Fix React.forwardedRef/memo props #8445

Merged
merged 4 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions addons/docs/src/blocks/Props.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ export const getPropsTableProps = (
const params = parameters || {};
const { component, framework = null } = params;

const target = of === CURRENT_SELECTION ? component : of;
let target = of === CURRENT_SELECTION ? component : of;
if (!target) {
throw new Error(PropsTableError.NO_COMPONENT);
}

if (target.render) {
target = target.render().type;
}
const { getPropDefs = inferPropDefs(framework) } = params.docs || {};
if (!getPropDefs) {
throw new Error(PropsTableError.PROPS_UNSUPPORTED);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { Button } from '@storybook/react/demo';

const ForwardedButton = React.forwardRef((props, ref) => <Button ref={ref} {...props} />);

export default {
title: 'Addons|Docs/ForwardRef',
component: ForwardedButton,
};

export const displaysCorrectly = () => <ForwardedButton>Hello World!</ForwardedButton>;
displaysCorrectly.story = { name: 'Displays forwarded ref components correctly' };