Skip to content

Ref doesnt work  #203

@theGABS

Description

@theGABS

If you specify additional props on the Tabs component they will be forwarded to the rendered div

I looked at your code, i can not use ref, because you use (and overwrite it)

render() {
    // Delete all known props, so they don't get added to DOM
    const {
      children, // unused
      className,
      disabledTabClassName, // unused
      focus, // unused
      forceRenderTabPanel, // unused
      onSelect, // unused
      selectedIndex, // unused
      selectedTabClassName, // unused
      selectedTabPanelClassName, // unused
      ...attributes
    } = this.props;

    return (
      <div
        {...attributes}
        className={cx(className)}
        onClick={this.handleClick}
        onKeyDown={this.handleKeyDown}
        ref={node => {
          this.node = node;
        }}
        data-tabs
      >
        {this.getChildren()}
      </div>
    );
}

Can u rewrite code something like

<div
        {...attributes}
        className={cx(className)}
        onClick={this.handleClick}
        onKeyDown={this.handleKeyDown}
        ref={node => {
          this.node = node;
          /* ____ ADDED LINE BELOW _____ */
          if (attributes.ref) {attributes.ref(node)}
        }}
        data-tabs
      >
        {this.getChildren()}
      </div>
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions