我是React的新手,我在React應(yīng)用程序中遇到了自定義類型定義的問題。我從Stoyan Stefanov的書中學(xué)到了知識(shí),并且有一個(gè)自定義類型定義的示例,但是當(dāng)我嘗試構(gòu)建應(yīng)用程序時(shí),出現(xiàn)了一個(gè)錯(cuò)誤:語法錯(cuò)誤:js / source / components / Button.js:意外的令牌,預(yù)期為“;” (9:5)我的代碼(從9行開始):type Props = { href: ?string, className: ?string,}const Button = (props: Props) => props.href ? <a {...props} className={classNames('Button', props.className)}/> : <button {...props} className={classNames('Button', props.className)}/>是否可以創(chuàng)建我自己的類型或者它是舊的標(biāo)準(zhǔn)?感謝您的任何評(píng)論!
反應(yīng)自定義類型定義
蕪湖不蕪
2021-04-07 17:15:18