So I am currently in this situation where I want to display my react application in the S3 bucket. When I deploy my application to the S3 bucket It gives me a static URL which I can see the application such as;
https://s3bucket.www.react-application.cloud/apps/calculationapp/24995X095636Fb9b5821/index.html
In my case I am seeing an empty page and my assumption is that there is some issues with the way I've configured my react routing inside of my index.js file;
index.js
const getBasename = path => path.substr(0, path.lastIndexOf('/'));
ReactDOM.render(
<BrowserRouter basename={getBasename(window.location.pathname)}>
<App />
</BrowserRouter>,
boostrapElement
);
The reason to why Im saying this is most likely the issue is that when I simply deploy it with;
ReactDOM.render(
<h1> Show me something ! </h1>
boostrapElement
);
it works perfectly and Im able to see the h1
App.js
class App extends Component {
render() {
return (
<React.Fragment>
<Route key="start-path" path='/' render={(props) => <HomeComponent {...props} filterData='HOME' />} />
<Route exact key="second-page" path='/react/second' render={(props) => <HomeComponent {...props} filterData='SECOND' />} />
<Route exact key="third-page" path='/react/third' render={(props) => <HomeComponent {...props} filterData='THIRD' />} />
</React.Fragment>
)
}
}