Skip to content

Instantly share code, notes, and snippets.

@wildfrontend
Last active September 30, 2020 03:54
Show Gist options
  • Save wildfrontend/3c6ca48712dee5b07782df4ac9323f77 to your computer and use it in GitHub Desktop.
Save wildfrontend/3c6ca48712dee5b07782df4ac9323f77 to your computer and use it in GitHub Desktop.
How to use bulma tabs active class name on the parent element with React router

jgthms/bulma#3129

answer:

  const setParentAsActive = (node: any) => {
    if (node) {
      node.parentNode.className = node.className
    }
  }
//tabs
      <div className="tabs">
        <ul>
          <li>
            <NavLink
              to={url}
              innerRef={setParentAsActive}
              exact
              activeClassName="is-active"
            >
              Product
            </NavLink>
          </li>

          <li>
            <a>Music</a>
          </li>
          <li>
            <a>Videos</a>
          </li>
          <li>
            <a>Documents</a>
          </li>
        </ul>
      </div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment