import React, { useEffect, useState } from "react";
import styles from "./index.module.scss";
import { urlParameter } from "@/utils/history";
import { useLocation } from "react-router-dom";
import Tab4Info from "../A2Main/Tab4Info";

function A3Goods() {
  const [id, setId] = useState(0);

  // 获取地址栏参数
  const location = useLocation();
  useEffect(() => {
    const obj = urlParameter(location.search);
    if (obj.id) setId(Number(obj.id));
    else alert("参数错误!");
  }, [location.search]);

  return (
    <div className={styles.A3Goods}>
      {id ? <Tab4Info id={id} isOpen={true} /> : null}
    </div>
  );
}

const MemoA3Goods = React.memo(A3Goods);

export default MemoA3Goods;
