Skip to content

Commit

Permalink
Combine into one file
Browse files Browse the repository at this point in the history
  • Loading branch information
ekosz committed Feb 14, 2017
1 parent 1181cba commit 8e0ad63
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 105 deletions.
50 changes: 0 additions & 50 deletions examples/connected-redux/src/App.js

This file was deleted.

108 changes: 93 additions & 15 deletions examples/connected-redux/src/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,101 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {
Actions as FarceActions,
BrowserProtocol,
createHistoryEnhancer,
queryMiddleware,
} from 'farce';
import {
createConnectedRouter,
createMatchEnhancer,
createRender,
foundReducer,
Matcher,
resolveElements,
} from 'found';
import FarceActions from 'farce/lib/Actions';
import BrowserProtocol from 'farce/lib/BrowserProtocol';
import createHistoryEnhancer from 'farce/lib/createHistoryEnhancer';
import queryMiddleware from 'farce/lib/queryMiddleware';
import createConnectedRouter from 'found/lib/createConnectedRouter';
import createMatchEnhancer from 'found/lib/createMatchEnhancer';
import createRender from 'found/lib/createRender';
import foundReducer from 'found/lib/foundReducer';
import Matcher from 'found/lib/Matcher';
import resolveElements from 'found/lib/resolveElements';
import Redirect from 'found/lib/Redirect';
import Link from 'found/lib/Link';
import { Provider } from 'react-redux';
import { combineReducers, compose, createStore } from 'redux';

import routeConfig from './routeConfig';
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 (async)
</LinkItem>
<LinkItem to="/baz">
Baz (redirects to Foo)
</LinkItem>
<LinkItem to="/qux">
Qux (missing)
</LinkItem>
</ul>
</ul>

{children}
</div>
);
}

App.propTypes = propTypes;

const routeConfig = [
{
path: '/',
Component: App,
children: [
{
Component: () => <div>Main</div>,
},
{
path: 'foo',
Component: () => <div>Foo</div>,
},
{
path: 'bar',
getComponent: () => new Promise((resolve) => {
setTimeout(resolve, 1000, ({ data }) => <div>{data}</div>);
}),
getData: () => new Promise((resolve) => {
setTimeout(resolve, 1000, 'Bar');
}),
render: ({ Component, props }) => ( // eslint-disable-line react/prop-types
Component && props ? (
<Component {...props} />
) : (
<div><small>Loading&hellip;</small></div>
)
),
},
new Redirect({
from: 'baz',
to: '/foo',
}),
],
},
];

const store = createStore(
combineReducers({
Expand Down
40 changes: 0 additions & 40 deletions examples/connected-redux/src/routeConfig.js

This file was deleted.

0 comments on commit 8e0ad63

Please sign in to comment.