export default function LinkNav()

in src/components/common/LinkNav/index.tsx [30:66]


export default function LinkNav(props: IProps) {
  useScrollHash();
  const { hash } = useLocation();
  const history = useHistory();

  useEffect(() => {
    if (hash === "") {
      history.replace({
        hash: props.defaultHash || props.config[0].id,
      });
    }
  }, []);
  return (
    <div className={props.className} style={props.style}>
      <ul className={styles.nav}>
        {props.config.map((item, index) => {
          return (
            <li
              className={clsx(
                styles.item,
                hash === `#${item.id}` && styles.active
              )}
              key={index}
            >
              <a
                href={`#${item.id}`}
                onClick={() => handleClickScroll(item.id)}
              >
                {item.label}
              </a>
            </li>
          );
        })}
      </ul>
    </div>
  );
}