forked from quran/quran.com-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
61 lines (49 loc) · 1.53 KB
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*global document, window, $ */
require('babel-polyfill');
import React from 'react';
import ReactDOM from 'react-dom';
import reactCookie from 'react-cookie';
import { Provider } from 'react-redux';
import { Router, browserHistory } from 'react-router';
import useScroll from 'scroll-behavior/lib/useStandardScroll';
import { ReduxAsyncConnect } from 'redux-async-connect';
import debug from 'debug';
import ApiClient from './src/helpers/ApiClient';
import createStore from './src/redux/create';
import routes from './src/routes';
const client = new ApiClient();
const history = useScroll(() => browserHistory)();
const store = createStore(history, client, window.__data);
window.quranDebug = debug;
window.ReactDOM = ReactDOM; // For chrome dev tool support
window.clearCookies = function() {
reactCookie.remove('quran');
reactCookie.remove('content');
reactCookie.remove('audio');
reactCookie.remove('isFirstTime');
};
// Init tooltip
if (typeof window !== 'undefined') {
$(function () {
$(document.body).tooltip({
selector: '[data-toggle="tooltip"]',
animation: false
});
});
}
const component = (
<Router render={(props) =>
<ReduxAsyncConnect {...props} helpers={{client}} />
} history={history}>
{routes()}
</Router>
);
debug('client', 'rehydrating app');
const mountNode = document.getElementById('app');
debug('client', 'React Rendering');
ReactDOM.render(
<Provider store={store} key="provider">
{component}
</Provider>, mountNode, () => {
debug('client', 'React Rendered');
});