i am new to react.i was trying dynamic routing but it is not working .
i was creating dynamic routing with react-router .i created on route named "/edit" and added that :id after it so i can dynamically access its value ..but whenever i go to http://localhost:8080/edit/22 it shows me this error
GET http://localhost:8080/edit/bundle.js net::ERR_ABORTED
Refused to execute script from 'http://localhost:8080/edit/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
and also doesn't render the page. see the screenshot.
part of code
const EditExpenseDashboardPage = (props) => {
console.log(props)
return (
<div>
<h3>EditExpense Dashboard page</h3>
<Link to="/add">Add</Link>
<Link to="/help">help</Link>
</div>
)}
const routes = (
<BrowserRouter>
<div>
<Header/>
<Switch>
<Route path="/" component={ExpenseDashboardPage} exact={true} />
<Route path="/add" component={AddExpenseDashboardPage} />
<Route path="/edit/:id" component={EditExpenseDashboardPage} />
<Route path="/help" component={HelpExpenseDashboardPage} />
<Route component={ErrorWala} />
</Switch>
</div>
</BrowserRouter>
)
thanks for help.
/editisn't a directory that exists in your project. Instead, it should be ( localhost:8080/bundle.js). Change you script src in index.html tosrc="./bundle.js"