-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
137 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Found Global Pending Example |
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,17 @@ | ||
{ | ||
"name": "global-pending", | ||
"version": "0.1.0", | ||
"private": true, | ||
"devDependencies": { | ||
"react-scripts": "0.7.0" | ||
}, | ||
"dependencies": { | ||
"found": "../..", | ||
"react": "^15.3.2", | ||
"react-dom": "^15.3.2", | ||
"react-static-container": "^1.0.1" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start" | ||
} | ||
} |
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,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Found Global Pending Example</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
</body> | ||
|
||
</html> |
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,105 @@ | ||
import createBrowserRouter from 'found/lib/createBrowserRouter'; | ||
import ElementsRenderer from 'found/lib/ElementsRenderer'; | ||
import Link from 'found/lib/Link'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import StaticContainer from 'react-static-container'; | ||
|
||
function LinkItem(props) { | ||
// TODO: Remove the pragma once evcohen/eslint-plugin-jsx-a11y#81 ships. | ||
return ( | ||
<li> | ||
<Link // eslint-disable-line jsx-a11y/anchor-has-content | ||
{...props} | ||
activeStyle={{ fontWeight: 'bold' }} | ||
/> | ||
</li> | ||
); | ||
} | ||
|
||
const propTypes = { | ||
children: React.PropTypes.node, | ||
}; | ||
|
||
function App({ children }) { | ||
return ( | ||
<div> | ||
<ul> | ||
<LinkItem to="/"> | ||
Main | ||
</LinkItem> | ||
<ul> | ||
<LinkItem to="/foo"> | ||
Foo | ||
</LinkItem> | ||
<LinkItem to="/bar"> | ||
Bar | ||
</LinkItem> | ||
</ul> | ||
</ul> | ||
|
||
{children} | ||
</div> | ||
); | ||
} | ||
|
||
App.propTypes = propTypes; | ||
|
||
const BrowserRouter = createBrowserRouter({ | ||
routeConfig: [ | ||
{ | ||
path: '/', | ||
Component: App, | ||
children: [ | ||
{ | ||
Component: () => <div>Main</div>, | ||
}, | ||
{ | ||
path: 'foo', | ||
getComponent: () => new Promise((resolve) => { | ||
setTimeout(resolve, 1000, () => <div>Foo</div>); | ||
}), | ||
}, | ||
{ | ||
path: 'bar', | ||
getComponent: () => new Promise((resolve) => { | ||
setTimeout(resolve, 1000, () => <div>Bar</div>); | ||
}), | ||
}, | ||
], | ||
}, | ||
], | ||
|
||
renderPending: () => ( | ||
<div> | ||
<StaticContainer> | ||
{null} | ||
</StaticContainer> | ||
|
||
<div | ||
style={{ | ||
position: 'absolute', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
background: 'white', | ||
opacity: 0.5, | ||
}} | ||
/> | ||
</div> | ||
), | ||
|
||
renderReady: ({ elements }) => ( // eslint-disable-line react/prop-types | ||
<div> | ||
<StaticContainer shouldUpdate> | ||
<ElementsRenderer elements={elements} /> | ||
</StaticContainer> | ||
</div> | ||
), | ||
}); | ||
|
||
ReactDOM.render( | ||
<BrowserRouter />, | ||
document.getElementById('root'), | ||
); |