Permalink
Browse files

Add examples (#20)

  • Loading branch information...
diegohaz committed May 26, 2018
1 parent 3271257 commit 86655819351ef2b0524ea8306186f0f1c798daf1
Showing with 1,634 additions and 50 deletions.
  1. +3 −0 .babelrc
  2. +2 −1 .eslintrc
  3. +1 −0 .gitignore
  4. +33 −0 examples/counter.js
  5. +12 −0 examples/index.html
  6. +20 −0 examples/index.js
  7. +4 −1 package.json
  8. +1,559 −48 yarn.lock
@@ -10,6 +10,9 @@
"stage-1",
"react"
],
"plugins": [
"transform-class-properties"
],
"env": {
"test": {
"plugins": [
@@ -14,6 +14,7 @@
"import/no-extraneous-dependencies": "off",
"react/forbid-prop-types": "off",
"react/jsx-filename-extension": "off",
"react/require-default-props": "off"
"react/require-default-props": "off",
"jsx-a11y/anchor-is-valid": "off"
}
}
@@ -3,3 +3,4 @@ node_modules
coverage
dist
*.log
.cache
@@ -0,0 +1,33 @@
import React from "react";
import { Provider, Container } from "../src";

const CounterContainer = props => (
<Container
initialState={{ count: 0 }}
actions={{
increment: amount => state => ({ count: state.count + amount })
}}
{...props}
/>
);

const CounterValue = () => (
<CounterContainer context="counter1">
{({ count }) => <div>{count}</div>}
</CounterContainer>
);

const CounterButton = () => (
<CounterContainer context="counter1">
{({ increment }) => <button onClick={() => increment(1)}>Increment</button>}
</CounterContainer>
);

const Counter = () => (
<Provider>
<CounterValue />
<CounterButton />
</Provider>
);

export default Counter;
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Constate examples</title>
</head>
<body>
<div id="root"></div>
<script src="./index.js"></script>
</body>
</html>
@@ -0,0 +1,20 @@
import React from "react";
import { render } from "react-dom";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import Counter from "./counter";

const App = () => (
<Router>
<div>
<ul>
<li>
<Link to="/counter">Counter</Link>
</li>
</ul>
<hr />
<Route path="/counter" component={Counter} />
</div>
</Router>
);

render(<App />, document.getElementById("root"));
@@ -20,10 +20,11 @@
"dist"
],
"scripts": {
"start": "parcel examples/index.html",
"test": "jest",
"coverage": "npm test -- --coverage",
"postcoverage": "opn coverage/lcov-report/index.html",
"lint": "eslint src test",
"lint": "eslint src test examples",
"clean": "rimraf dist",
"prebuild": "npm run clean",
"build": "rollup -c",
@@ -81,10 +82,12 @@
"jest-serializer-html": "^5.0.0",
"npm-watch": "^0.3.0",
"opn-cli": "^3.1.0",
"parcel-bundler": "^1.8.1",
"prettier": "^1.11.1",
"raf": "^3.4.0",
"react": "^16.3.0",
"react-dom": "^16.3.0",
"react-router-dom": "^4.2.2",
"react-test-renderer": "^16.3.0",
"rimraf": "^2.6.2",
"rollup": "^0.59.2",
Oops, something went wrong.

0 comments on commit 8665581

Please sign in to comment.