在这里尝试一些非常简单的东西。。。
import React, { ReactNode } from "react";
const MyButton = ({ children: ReactNode }) => {
return <div>MyButton</div>;
};
export default MyButton;
这一行const MyButton = ({ children: ReactNode }) => {突出显示标题中的错误。
package.json 看起来像这样
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.12",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
我需要安装其他库吗?我刚做了create-react-app --template typescript