Skip to content

Instantly share code, notes, and snippets.

@maddrag0n
Last active February 24, 2018 02:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maddrag0n/32e40234d4dface26869ee72036c34b5 to your computer and use it in GitHub Desktop.
Save maddrag0n/32e40234d4dface26869ee72036c34b5 to your computer and use it in GitHub Desktop.
ReactJS live boilerplate (single html with router, react-bootstrap, fetch, lodash). Created for training purposes. Released under BSD-3-Clause.
<!doctype html>
<html lang="en" itemscope itemtype="http://schema.org/Product">
<head>
<title>ReactJS Live Boilerplate</title>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, width=device-width">
<link data-description="bootstrap styles" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="http://unpkg.com/babel-standalone@6/babel.min.js">/* <script type='text/babel'> */</script>
<script src="http://unpkg.com/react@latest/umd/react.development.js">/* exposes React */</script>
<script src="http://unpkg.com/react-dom@latest/umd/react-dom.development.js">/* exposes ReactDOM */</script>
<script src="https://unpkg.com/react-router-dom@latest/umd/react-router-dom.min.js">/* exposes ReactRouterDom */</script>
<script src="https://unpkg.com/prop-types@latest/prop-types.min.js">/* exposes PropTypes */</script>
<script src="https://unpkg.com/react-bootstrap@latest/dist/react-bootstrap.min.js">/* exposes ReactBootstrap */</script>
<script src="https://unpkg.com/lodash@latest/lodash.min.js">/* exposes _ */</script>
<script src="https://unpkg.com/whatwg-fetch@latest/fetch.js">/* fetch polyfill, exposes fetch */</script>
</head>
<body>
<script type='text/babel'>
/**
* The following list of globals are available
* without any further action. The list is for your reference
* and has no other function.
*
* **React**
* @global React [ReactJS](https://reactjs.org/docs/react-api.html)
* @global ReactDOM [ReactDOM](https://reactjs.org/docs/react-dom.html)
* @global PropTypes [prop-types component props checking](https://reactjs.org/docs/typechecking-with-proptypes.html)
* @global ReactRouterDom [react-router](https://reacttraining.com/react-router/web/api/HashRouter)
*
* **Tools**
* @global _ [Lodash (js utilities)](https://lodash.com/docs/)
* @global fetch [Fetch API (http client)](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)
*
* **View libraries**
* @global ReactBootstrap [react-bootstrap](https://react-bootstrap.github.io/getting-started/introduction)
*
*/
/**
* Your main container
* @extends React
*/
class App extends React.Component {
render() {
return (
<ReactRouterDOM.HashRouter>
<div style={{ padding: 24 }}>
{this.renderHeadline()}
</div>
</ReactRouterDOM.HashRouter>
);
}
renderHeadline = () => (
<ReactBootstrap.PageHeader>
ReactJS Live Boilerplate <small>by <a href='https://github.com/maddrag0n'>maddrag0n</a></small>
</ReactBootstrap.PageHeader>
);
}
/**
* this part renders your react app into the DOM
* @param {ReactElement} the react app to render
*/
((reactAppElement) => {
const domTarget = document.getElementsByTagName('body')[0].appendChild(document.createElement('react-app'));
domTarget.setAttribute('description', 'this is your ReactDOM render target');
ReactDOM.render(
reactAppElement,
domTarget,
);
})(<App/>);
</script>
</body>
</html>
<!--
BSD-3-Clause
Copyright 2018 Josh Li
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment