I go to the url that matches the path or a route and the component in not getting rendered. I also have wrapped every thing with BrowserRouter in index.js file as well. Can't figure out the problem here. Help me pls.
Here is code
import { Route, Switch } from "react-router-dom";
<Switch>
<Route
path="comments/:curPage"
render={(props) => <List {...props} comments={comments} />}
/>
<Route path="test" exact component={Test} />
</Switch>
Here is index.js file
ReactDOM.render(
<BrowserRouter>
<React.StrictMode>
<App />
</React.StrictMode>
</BrowserRouter>,
document.getElementById("root")
);
My package.json file
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"react-scroll-to-bottom": "^4.1.2",
"socket.io-client": "^4.1.3",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
When I go to the url comments/1 The content in <List /> component is not getting rendered. Why?