1
1
mirror of https://github.com/c8r/x0.git synced 2024-09-11 21:57:26 +03:00

Remove router wrapper

This commit is contained in:
Brent Jackson 2017-12-14 16:18:02 -05:00
parent 8889e9a60e
commit f25d62d3a2
4 changed files with 21 additions and 36 deletions

View File

@ -11,14 +11,15 @@ npm install @compositor/x0
## Features
- Zero-config
- Hot-loading development environment
- Works with virtually any React component\*
- No convoluted APIs
- No confusing APIs
- Renders static HTML
- Renders JS bundles
- Use any CSS-in-JS library
- Routing with [react-router][react-router]
- Async data fetching
- Support for routing with [react-router][react-router]
- Support for async data fetching
\* Components cannot rely on bundler features like webpack loaders
@ -136,16 +137,27 @@ To render multiple pages and use routing, add a `routes` array to the `package.j
x0 static src/App.js --out-dir site
```
<!--
For easier integration with [react-router][react-router], use the x0 Router component, which handles universal rendering.
The current route will be passed to the component as `props.pathname`.
This can be used with [react-router][react-router]'s StaticRouter and BrowserRouter components.
```jsx
// Example with react-router
import React from 'react'
import Router from '@compositor/x0/Router'
import { Route, Link } from 'react-router-dom'
import {
StaticRouter,
BrowserRouter,
Route,
Link
} from 'react-router-dom'
import Home from './Home'
import About from './About'
// universal router component
const Router = typeof document !== 'undefined'
? BrowserRouter
: StaticRouter
const App = props => (
<Router
basename={props.basename}
@ -167,8 +179,6 @@ const App = props => (
)
```
-->
[Made by Compositor](https://compositor.io/)
|
[MIT License](LICENSE.md)

View File

@ -1,24 +0,0 @@
const React = require('react')
const {
BrowserRouter,
StaticRouter,
Route,
Link
} = require('react-router-dom')
const UniversalRouter = typeof document !== 'undefined' ? BrowserRouter : StaticRouter
const h = React.createElement
const Router = props => h(UniversalRouter, props,
h('div', null, props.children)
)
Router.defaultProps = {
context: {}
}
module.exports = Router
module.exports.Route = Route
module.exports.Link = Link

View File

@ -1,3 +1,2 @@
module.exports.dev = require('./dev')
module.exports.static = require('./static')
module.exports.Router = require('./Router')

View File

@ -34,8 +34,6 @@
"ora": "^1.3.0",
"pkg-up": "^2.0.0",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"read-pkg-up": "^2.0.0",
"update-notifier": "^2.2.0",
"webpack": "^3.10.0",
@ -47,6 +45,8 @@
"isomorphic-fetch": "^2.2.1",
"nano-style": "^1.0.0-20",
"nyc": "^11.2.1",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2",
"refunk": "^2.0.0-1",
"styled-components": "^2.2.4",
"styled-system": "^1.0.7"