Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update react-automata #87

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions React/react-automata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@
"main": "src/index.js",
"dependencies": {
"packlist-components": "1.2.0",
"react": "16.3.2",
"react-automata": "^3.0.0",
"react-dom": "16.3.2",
"react-scripts": "1.1.4"
"react": "16.5.2",
"react-automata": "^4.0.4",
"react-dom": "16.5.2",
"react-scripts": "2.0.4",
"react-test-renderer": "^16.5.2"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
9 changes: 6 additions & 3 deletions React/react-automata/src/Statecharts/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const isEmpty = ({ value }) => value === "";
const isNotEmpty = state => !isEmpty(state);
const isTrue = () => true;

export default {
initial: "idle",
Expand All @@ -8,7 +9,8 @@ export default {
on: {
CLEAR: {
idle: {
actions: ["clear"]
actions: ["clear"],
cond: isTrue
}
},
SET_NEW_ITEM_NAME: {
Expand All @@ -27,8 +29,9 @@ export default {
},
CLEAR: {
loaded: {
actions: ["clear"]
}
actions: ["clear"],
cond: isTrue
},
},
SET_NEW_ITEM_NAME: {
loaded: {
Expand Down
10 changes: 5 additions & 5 deletions React/react-automata/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
************************************************/
import React, { Component } from "react";
import { render } from "react-dom";
import { State, withStatechart } from "react-automata";
import { State, withStateMachine } from "react-automata";
import statechart from "./Statecharts/index";
import ListItems from "./Components/listItems";
import AddItems from "./Components/addItem";
Expand Down Expand Up @@ -46,14 +46,14 @@ export class App extends Component {
handleSetNewItemName = event => {
this.props.transition("SET_NEW_ITEM_NAME", { value: event.target.value });
};
handleClear = () => this.props.transition("CLEAR");
handleClear = () => this.props.transition("CLEAR", true);

render() {
return (
<div style={styles}>
<h2>Welcome to setState + react-automata</h2>
<State value="idle">Current State 'idle'</State>
<State value="loaded">Current State 'loaded'</State>
<State is="idle">Current State 'idle'</State>
<State is="loaded">Current State 'loaded'</State>
<AddItems
addItem={this.handAddItem}
setNewItemText={this.handleSetNewItemName}
Expand All @@ -66,7 +66,7 @@ export class App extends Component {
}
}

const WrappedWithChart = withStatechart(statechart)(App);
const WrappedWithChart = withStateMachine(statechart)(App);
export default WrappedWithChart;

render(<WrappedWithChart />, document.getElementById("root"));
Loading