Skip to content

Instantly share code, notes, and snippets.

@jsteenkamp
Created June 14, 2016 01:17
Show Gist options
  • Save jsteenkamp/c5df29336a2cbbbf743e82b2b13444de to your computer and use it in GitHub Desktop.
Save jsteenkamp/c5df29336a2cbbbf743e82b2b13444de to your computer and use it in GitHub Desktop.
React Stand Alone component with config
// only entry point for CSS processed via webpack
import '../styles/main.scss';
import React from 'react';
import { render } from 'react-dom';
import { browserHistory } from 'react-router';
import configureStore from './store';
import root, { Root } from './root';
const store = configureStore(root.rootInitialState);
const routes = root.rootRoutes(store.getState);
store.runSaga(root.rootSaga);
let grid = {
configData: (data) => {
console.log(data);
},
renderGrid: (config) => {
render(
<Root store={ store } history={ browserHistory } routes={ routes }/>,
document.getElementById(config)
);
}
};
// rendered by React
grid.renderGrid('root');
// or export to global and then render manually via script with grid.render(elemId)
window.grid = grid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment