Application Entry Point - app.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 | import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { settings } from './settings';
import { Router, Route, browserHistory } from 'react-router';
import { Dashboard } from '../src/ReactDashboard';
let _settings;
if (typeof expressDashSettings != "undefined") {
_settings = expressDashSettings;
} else {
_settings = settings;
}
// We extend the Dashboard so we can pass Routing info from the App
class MyDashboard extends Component {
render() {
let z = {};
z.appliedFilters = (this.state) ? this.state.appliedFiltersi : {};
const props = Object.assign({}, this.props, z, _settings);
return <Dashboard {...props}/>
}
}
// Wrap Dashboard component in router
class App extends Component {
render() {
return (
<div id="router-container">
<Router history={browserHistory}>
<Route path='*' component={MyDashboard} />
<Route path='/react-dashboard' component={MyDashboard} />
</Router>
</div>
)
}
}
// Now put it in the DOM!
document.addEventListener('DOMContentLoaded', function(event) {
ReactDOM.render(<App/>, document.getElementById('root'));
});
|
If you need to do custom initialization of data that cannot be accomodated with the existing backends, do it here. @@TODO Add example of custom fetch code here