Trowel tools
Helpers for Trowel
These helpers help you to make React application using:
- react-redux
- react-router-dom@4.0.0-beta.4
- react-hot-loader@3.0.0-beta.6
Here's an example of your App component:
/*--- App.jsx ---*/import Component PropTypes from 'react';import createStore from 'redux';import getMyInitialState from '../redux/my-initial-state.js';import myReducer from '../redux/my-reducer.js'; /* it is a very root application component NOT NEEDED to be wrapped in react-redux, react-router or react-hot-loader conatiners*/ { return <div>propsappDatagreating</div> ; } ApppropTypes = appData: PropTypes; // REQUIRED: static function creating redux storeApp ;
trowelTools.bundle
(App: React.Component) => {
initClient: (
appState?: any = {},
appData?: any = {},
mountElementId?: string = 'mount'
) => void
}
Helps you to wrap your App component by:
<Provider>
from react-redux<BrowserRouter>
from react-router-dom<AppContainer>
from react-hot-loader
/*--- index.js – entry file for webpack ---*/;; const appBundle = ; // will be passed as appData propconst appData = greating: 'Hello World!'; appBundle; // if hot-module-replacement is enabledif modulehot modulehotaccept'./App.jsx' { const NextApp = default; // .updateClient method will appear after you called .initClient appBundle; };
trowelTools.initSSR
(
App: React.Component,
params: {
location: string,
routerContext: {},
appState?: any,
appData?: any
}
) => React$Element
Helps you to wrap your App component by:
<Provider>
from react-redux<StaticRouter>
from react-router-dom<AppContainer>
from react-hot-loader
/*--- ssr.js – Server-Side rendering ---*/;;;; { const routerContext = {}; const appState = ; const appData = greating: 'Hello World!' ; const app = ; return ;}