no issue

- Extract root div id so its easy to change it in one place in future
- Add stripe load method
- Extract all initial non-ui handling to setup method
This commit is contained in:
Rish 2020-05-27 18:03:22 +05:30
parent 9cf8e0e435
commit a9a083f2f1

View File

@ -4,10 +4,11 @@ import './index.css';
import App from './App';
const handleDataAttributes = require('./data-attributes');
const ROOT_DIV_ID = 'ghost-membersjs-root';
function addRootDiv() {
const elem = document.createElement('div');
elem.id = 'ghost-membersjs-root';
elem.id = ROOT_DIV_ID;
document.body.appendChild(elem);
}
@ -33,15 +34,20 @@ function handleTokenUrl() {
}
}
function init() {
function setup() {
loadStripe();
addRootDiv();
handleDataAttributes({siteUrl: window.location.origin});
handleTokenUrl();
}
function init() {
setup();
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('ghost-membersjs-root')
document.getElementById(ROOT_DIV_ID)
);
}