I had created a fresh react project with typescript using the following command:
npx create-react-app . --template typescript
I am creating a new component in SchemesSelector.tsx
:
import React from 'react';
interface Scheme {
id: number,
display_name: string,
}
export interface Props {
schemes: Array<Scheme>;
}
const SchemesSelector = (props: Props) => {
return (
<div>
<p>Select Schemes:</p>
{props.schemes}
</div>
);
};
export default SchemesSelector;
However I am getting the following error at the div
's opening tag:
TS2746: This JSX tag's 'children' prop expects a single child of type 'ReactNode', but multiple children were provided.
The following is my package.json
:
{
"name": "test",
"version": "0.1.0",
"private": true,
"dependencies": {
"@reduxjs/toolkit": "^1.9.2",
"@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.28",
"@types/react-dom": "^18.0.10",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"bootstrap": "^5.2.3",
"eslint-config-google": "^0.14.0",
"eslint-plugin-jsdoc": "^40.0.0",
"node-sass": "^7.0.3",
"react": "^18.2.0",
"react-bootstrap": "^2.7.2",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.8.1",
"react-scripts": "5.0.1",
"redux": "^4.2.1",
"typescript": "^4.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"plugins": [
"@typescript-eslint",
"jsdoc"
],
"extends": [
"react-app",
"react-app/jest",
"plugin:jsdoc/recommended",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"google"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I am fairly new to react. I tried several solutions available online but nothing worked.
Can anyone help me understand where I am going wrong?
Thanks