score:9
use this on top of your javascript:
var router = reactrouter.router;
var route = reactrouter.route;
var indexroute = reactrouter.indexroute;
var link = reactrouter.link;
var browserhistory = reactrouter.browserhistory;
and remove the import
statements.
i'm currently using this react-router package: https://unpkg.com/react-router@3.0.0/umd/reactrouter.js
edit:
here's an example at codepen: http://codepen.io/lsmoura/pen/pnpozp -- it uses no import statements.
score:10
here's a minimal example of how this can be accomplished:
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<script src='https://unpkg.com/react@16.3.1/umd/react.production.min.js'></script>
<script src='https://unpkg.com/react-dom@16.3.1/umd/react-dom.production.min.js'></script>
<script src='https://unpkg.com/react-router-dom@5.0.0/umd/react-router-dom.min.js'></script>
<script src='https://unpkg.com/babel-standalone@6.26.0/babel.js'></script>
</head>
<body>
<div id='root'></div>
<script type='text/babel'>
const link = reactrouterdom.link,
route = reactrouterdom.route;
const app = props => (
<reactrouterdom.hashrouter>
<ul>
<li><link to="/">to home</link></li>
<li><link to="/a">to a</link></li>
<li><link to="/b">to b</link></li>
</ul>
<route path="/" exact component={home} />
<route path="/a" component={a} />
<route path="/b" component={b} />
</reactrouterdom.hashrouter>
)
const home = props => <h1>home</h1>
const a = props => <h1>a</h1>
const b = props => <h1>b</h1>
reactdom.render(<app />, document.queryselector('#root'));
</script>
</body>
</html>
score:20
for react route v4.0,please read react-router package add two js link on your page:
<script src="https://unpkg.com/react-router/umd/react-router.min.js"></script>
<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script>
in js code you can use :
const router = window.reactrouterdom.browserrouter;
const route = window.reactrouterdom.route;
const link = window.reactrouterdom.link;
const prompt = window.reactrouterdom.prompt;
const switch = window.reactrouterdom.switch;
const redirect = window.reactrouterdom.redirect;
also,can use
console.log(window.reactrouterdom);
to out put all object like:
Source: stackoverflow.com
Related Query
- Using React Router with CDN and without webpack or browserify
- using mobx with react functional components and without decorators
- Using React Router and Webpack 2 how to require external libraries only on certain routes?
- Error using component done with react,redux and react-redux and build with webpack in react application
- CSS Code Splitting with Webpack 2 and React Router
- Using webpack and react × becomes × with minification
- Dynamically load javascript chunk with webpack and react router
- React Router difference between component with and without function
- React router with basename and webpack initial url
- react scroll to a component without react router and with most basic code
- Navigating with React router without using links
- Is there a way to load react library files separately and not in the bundled files when using react with babel, webpack and gulp as building tool?
- React Memory Leakage with typescript using google firestore and react router
- using React router with history.js via CDN
- React router - click on card and redirect to a new page with content of that card (card details) using useParams and reacthooks
- React router is not working with webpack server and redux?
- How to click a button and navigate to a new route with URL params using React Router 4
- Im using React Router and I want one of my route links with path="/" to be the home page on reload.. How can you do that?
- Circular dependencies with node modules import using Browserify and React
- Undefined < in app.jsx. using react.js, react router and webpack
- I want to popup each item to view and edit . How can I do this using modal with router in react js?
- Using React Router with Switch and can't get the page to render different components when changing routes
- Using specific filename for React components and containers with Webpack
- how to write one GET api call using axios instance with and without params in React JS
- Add Favicon with React and Webpack
- How to import CSS modules with Typescript, React and Webpack
- You should not use Route or withRouter() outside a Router when using react-router 4 and styled-component in react
- How to set up Babel 6 stage 0 with React and Webpack
- How to mock history.push with the new React Router Hooks using Jest
- Using onBlur with JSX and React
More Query from same tag
- unable to display count on the barchart (svg graph)
- Why I Can not get data from mongodb database?
- How do I initiate Storybook?
- Issue with import statement file paths
- I am trying to do sorting local json file in React js but getting error: "TypeError: _Data_place_json__WEBPACK_IMPORTED_MODULE_1__ is not iterable."
- getFirebase is not a function error using firebase auth create user
- Getting Text Input value with Redux in a React App
- React axios form
- Center text correctly in background color
- Rendering new component on click in react
- How routing with react-router-dom?
- Could not get BatchBridge, make sure your bundle is packaged correctly
- how to get cookie in react passed from express js api (MERN stack)
- What are the guarantees on React lifecycle event order between components?
- Locomotive Scroll with React 17
- Blank page when deploying React App to gh pages
- React - What is the best way to handle login and authentication?
- Infow window onclick is not working
- Want to hide Navbar on Login Page of React application
- React setInterval inside useEffect
- How to implement file Download button in Next.js? (window is not defined)
- setState doesn t work in a promise. State undefined with React
- Doing a countdown in React
- Redux form cannot type
- Res.download() working with html form submit but not an Axios post call
- Javascript `this` - reference containing object
- Two or more buttons triggering the same Material-UI Popper element
- Global styles for specific pages in next js
- How do export a React component with related "child" components
- How can i get the updated state value in useEffect