diff --git a/README.md b/README.md index 839d015..3733831 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,12 @@ If `accordion` is true, only one panel can be open. Opening another panel will Content to render in the right of the panel header + + wrappedComponentRef + inst => this.ref = inst + null + get panel dom ref + diff --git a/src/Panel.jsx b/src/Panel.jsx index deb34af..dccce49 100644 --- a/src/Panel.jsx +++ b/src/Panel.jsx @@ -41,6 +41,7 @@ class CollapsePanel extends Component { forceRender, expandIcon, extra, + wrappedComponentRef, } = this.props; const headerCls = classNames(`${prefixCls}-header`, { [headerClass]: headerClass, @@ -55,8 +56,16 @@ class CollapsePanel extends Component { if (showArrow && typeof expandIcon === 'function') { icon = expandIcon(this.props); } + const panelProps = { + id, + style, + className: itemCls, + }; + if (wrappedComponentRef) { + panelProps.ref = wrappedComponentRef; + } return ( -
+
{showArrow && icon} {header} - {extra && (
{extra}
)} + {extra &&
{extra}
}