sparksuite / react-accessible-dropdown-menu-hook

A simple Hook for creating fully accessible dropdown menus in React
http://sparksuite.github.io/react-accessible-dropdown-menu-hook
MIT License
112 stars 26 forks source link

MenuItems as Link of React Router #281

Closed priyankalad closed 3 years ago

priyankalad commented 3 years ago

Is there a way to use Link(React Router) instead of anchor tag as menu items.

priyankalad commented 3 years ago

Resolved. Solution: passed itemProps[index].ref as innerRef to Link element example:

    const { ref, ...rest } = itemProps[idx]
            return (
              <Link
                      className={ddMenuItemCSS}
                      key={idx}
                      {...rest}
                      to={item.link}
                      id={`menuitem${idx}_${dataKey}`}
                      innerRef={ref}>
                      {item.name}
              </Link>
            )