I need to get a react with react router website running without getting served to a web server so my higher ups can look up on it. As per my boss' instruction, I am tasked to send him the index.html
file with all the piled static files(js/css/img) to load on it so they can view my work.
I have already told my boss that I can send him the site with the package.json
on so all he has to do is run npm install
to get the dependencies and run the script to startup the dev server, however, he has told me that he has to present it to people who will not have node
installed. What should I do?
I need to get a react with react router website running without getting served to a web server so my higher ups can look up on it. As per my boss' instruction, I am tasked to send him the index.html
file with all the piled static files(js/css/img) to load on it so they can view my work.
I have already told my boss that I can send him the site with the package.json
on so all he has to do is run npm install
to get the dependencies and run the script to startup the dev server, however, he has told me that he has to present it to people who will not have node
installed. What should I do?
npm
, node
and even React, yet you don't have fundamental understanding of what they all produce? It's not a criticism, it's just that you have the hard part done but the simple part is what's not clicking with you.
– Mjh
Commented
Oct 3, 2017 at 7:40
index.html
on a browser file nothing came up
– edohedo
Commented
Oct 3, 2017 at 7:47
With react-router
v4.x.x you can use <HashRouter />
import { HashRouter } from 'react-router-dom'
<HashRouter>
<App/>
</HashRouter>
For further information see the following link
with react-router
v3.x.x use hasHistory
:
import React from 'react'
import { render } from 'react-dom'
import { hashHistory, Router, Route, IndexRoute } from 'react-router'
import App from '../ponents/App'
import Home from '../ponents/Home'
render(
<Router history={hashHistory}>
<Route path='/' ponent={App}>
<IndexRoute ponent={Home} />
</Route>
</Router>,
document.getElementById('app')
)
For further information see the following link
You can load react-router
as well as react
by using unpkg
:
<script src="https://unpkg./[email protected]/umd/react-router.min.js"></script>
you may try adding "homepage": "."
to your project package.json; this will instruct react scripts to set all paths relative to index.html.
Of course, this won't work if your website is unicating with a server backend or have client-side routing logic ( as it seems ). create-react docs mentions react-router basename prop to fix the client-side routing issue ...