Last active
August 8, 2017 12:51
-
-
Save yosevu/3232bbcb6928dd0e6bc1f58981683f83 to your computer and use it in GitHub Desktop.
Index
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import './index.css'; | |
| import App from './App'; | |
| // Get the element to prepend our app to from https://www.google.com. | |
| // This could be a specific element on a website or something more general like `document.body`. | |
| const viewport = document.getElementById('viewport'); | |
| // Create a div to render the App component to. | |
| const app = document.createElement('div'); | |
| // Set the app element's id to `root`. | |
| // This name is the same as the element that create-react-app renders to by default | |
| // so it will work on the development server too. | |
| app.id = 'root'; | |
| // Prepend the App to the viewport element in production if it exists on the page. | |
| // You could also use `appendChild` depending on your needs. | |
| if (viewport) viewport.prepend(app); | |
| // Render the App. | |
| ReactDOM.render(<App />, document.getElementById('root')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment