https://github.com/pitou/redux-easy-app
Wrapper library for a Redux Isomorphic App with Router
https://github.com/pitou/redux-easy-app
Last synced: about 1 year ago
JSON representation
Wrapper library for a Redux Isomorphic App with Router
- Host: GitHub
- URL: https://github.com/pitou/redux-easy-app
- Owner: pitou
- License: mit
- Created: 2015-11-05T20:25:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T07:54:36.000Z (over 3 years ago)
- Last Synced: 2025-04-19T05:12:12.518Z (about 1 year ago)
- Language: JavaScript
- Size: 1.23 MB
- Stars: 131
- Watchers: 7
- Forks: 4
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
redux-easy-app
==============
This library can help you reduce the boilerplate of a **Redux isomorphic app** to the minimum.
Installation
------------
You can install the package using:
npm install redux-easy-app
However, if you are starting to write an app from scratch, you may consider downloading the
[redux-app-skeleton](https://github.com/pitou/redux-app-skeleton), which depends on this module and
already uses the functions explained in the following section.
Redux'(s?) function wrappers
----------------------------
*redux-easy-app* exposes only three functions:
**createContainer()**
Binds a component to his props and actions.
You may want use this one on every component that interacts in any way with the state of the application.
createContainer(ExampleComponent, SomeActions, mapStateToProps);
**renderClientApp()**
Renders the app in the browser, given its routes and reducers.
renderClientApp({
routes,
reducers,
appRootElement
});
**startServerApp()**
This one needs a larger number of options but takes care of a lot of things: isomorphism, data pre-fetch,
state push into the tree of routes.
You have to provide an instance of an Express app as first argument. The **request** object will be internally
used to decide which route has been requested and fetch the data accordingly, the **response** object will
be used to send the rendered HTML.
The *viewFilename* option refers to a [nunjucks](https://www.npmjs.com/package/nunjucks) template file, usually the index.html of your app.
In the future, other template engines will be supported too.
startServerApp(app, {
routes,
reducers,
routesFetchersMap,
viewsFolderPath,
viewFilename
});
The option *routesFetchersMap* should be an array of objects having the format specified in
[this example](https://github.com/pitou/redux-app-skeleton/blob/master/src/server/routesFetchersMap.js).
Given a certain route, the server app will call the function that you specified as the *func* parameter
and then the page will be rendered with the fetched data.