Last active
October 29, 2016 08:00
-
-
Save jcblw/e825f57a3c20d26f0918 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample of how the api could look | |
// this is setting up the server, putting in some routes and configuring them. | |
import ComponentServer from 'react-component-server' | |
import Component from './components/Component' | |
import template from './templates/_layout' | |
const port = process.env.PORT || 3000 | |
const componentServer = ComponentServer.create({ | |
server: server, // optionally pass in own express server | |
precompile: ['/explore', '/manage'], // paths to precompile | |
doctype: '<!doctype html>', // doctype this is the default, but it could be changed here | |
defaults: { | |
component: Component, // explict passing of component | |
props: {}, | |
template: template // explict passing of layout | |
} | |
}) | |
/* | |
Upsides of explict passing of components, | |
- no dealing with pathing in lib | |
- very straight forward | |
Downsides | |
- not so clear how bundling then can happen | |
*/ | |
// listen to port | |
componentServer.listen(port); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment