React Basic Functional Component

Date: 2021-01-11
export function Name(props: { id: string }) {
    const [records, setRecords] = useState<string[]>([]);
    const { id } = props;
    useEffect(() => {
        if (!id) return;
        const load = async () => {
            const data = await getDataById(id);
            setRecords(data);
        };
        load();
    }, [id]);
    return <>{records}</>;
};
44320cookie-checkReact Basic Functional Component