This repository has been archived by the owner on Jun 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements Cliend & Server Side Rendering using Found
- Loading branch information
1 parent
7564071
commit 3de0d0a
Showing
8 changed files
with
113 additions
and
66 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* @flow */ | ||
|
||
export { default } from './App'; | ||
export { default as App } from './App'; | ||
export { default as routeConfig } from './routeConfig'; | ||
export { default as renderConfig } from './renderConfig'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* flow */ | ||
|
||
import React from 'react'; | ||
import createRender from 'found/lib/createRender'; | ||
import App from './App'; | ||
import Error404 from './Error404'; | ||
|
||
// createRender({ renderPending, readyReady, renderError }) | ||
export default createRender({ | ||
renderError: ({ error }) => ( // eslint-disable-line react/prop-types | ||
<div> | ||
{error.status === 404 ? <App><Error404 /></App> : 'Error'} | ||
</div> | ||
), | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* @flow */ | ||
|
||
import React from 'react'; | ||
import makeRouteConfig from 'found/lib/jsx/makeRouteConfig'; | ||
import Route from 'found/lib/jsx/Route'; | ||
import { CodeSplit } from 'code-split-component'; | ||
import type { ReactElement } from '../../types/react'; | ||
import App from './App'; | ||
|
||
function routeRender({ Component, props }: {Component: ReactElement, props?: any}) { | ||
if (!Component || !props) { | ||
return <div><small>Loading…</small></div>; | ||
} | ||
|
||
return <Component {...props} />; | ||
} | ||
|
||
function CodeSplitHome() { | ||
return ( | ||
<CodeSplit chunkName="home" modules={{ Home: require('./Home') }}> | ||
{ ({ Home }) => Home && <Home /> } | ||
</CodeSplit> | ||
); | ||
} | ||
|
||
function CodeSplitAbout() { | ||
return ( | ||
<CodeSplit chunkName="about" modules={{ About: require('./About') }}> | ||
{ ({ About }) => About && <About /> } | ||
</CodeSplit> | ||
); | ||
} | ||
|
||
export default makeRouteConfig( | ||
<Route | ||
path="/" | ||
Component={App} | ||
> | ||
<Route | ||
Component={CodeSplitHome} | ||
render={routeRender} | ||
/> | ||
<Route | ||
path="about" | ||
Component={CodeSplitAbout} | ||
render={routeRender} | ||
/> | ||
</Route>, | ||
); |