Answer the question
In order to leave comments, you need to log in
Why does React throw Not Found on page refresh?
Good morning!
Can you please tell me why this happens and how can I solve the problem?
I'm using React with Laravel, Apache throws an error.
Here is my code:
index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom'
import App from './components/App';
if (document.getElementById('example')) {
ReactDOM.render(<BrowserRouter><App /></BrowserRouter>, document.getElementById('example'));
}
import React, { Component } from 'react';
import { Switch, Route, Link } from 'react-router-dom';
import Tutorial from "./Tutorial";
const Sandwiches = () => <h2>Sandwiches</h2>;
const Tacos = () => <h2>Tacos</h2>;
class App extends Component {
render() {
return (
<div>
<ul>
<li><Link to='/sandwiches'>Sandwiches</Link></li>
<li><Link to='/tacos'>Tacos</Link></li>
<li><Link to='/tutorials'>Tutorials</Link></li>
</ul>
<Switch>
<Route exact path='/sandwiches' component={Sandwiches} />
<Route exact path='/tacos' component={Tacos} />
<Route exact path='/tutorials' component={Tutorial} />
</Switch>
</div>
);
}
}
export default App;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question