Skip to content

Commit

Permalink
Merge pull request #6 from dcwither/dcwither/fix-examples
Browse files Browse the repository at this point in the history
Dcwither/fix examples
  • Loading branch information
dcwither committed Aug 24, 2018
2 parents 159ee86 + c4bf205 commit 5635bce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion examples/question-form.js
Expand Up @@ -58,7 +58,7 @@ export default class QuestionForm extends React.Component {
value: { id },
onCancel
} = this.props;
if (id) {
if (!isNil(id)) {
return (
<React.Fragment>
<Button variant="raised" color="default" onClick={onCancel}>
Expand Down
30 changes: 15 additions & 15 deletions examples/questions-with-form.js
Expand Up @@ -11,8 +11,18 @@ export default class QuestionsWithForm extends React.Component {

state = {
nextId: 2,
questions: [
{
questions: {
0: {
author: {
firstName: "Bob",
lastName: "B"
},
body: "I installed package x and now my code doesn't work.",
id: 0,
tags: ["javascript"],
title: "I have a bug"
},
1: {
author: {
firstName: "Alice",
lastName: "A"
Expand All @@ -22,18 +32,8 @@ export default class QuestionsWithForm extends React.Component {
id: 1,
tags: ["react", "redux"],
title: "How do I connect a component to react redux"
},
{
author: {
firstName: "Bob",
lastName: "B"
},
body: "I installed package x and now my code doesn't work.",
id: 0,
tags: ["javascript"],
title: "I have a bug"
}
]
}
};

handleCommit = (message, value) => {
Expand All @@ -56,7 +56,7 @@ export default class QuestionsWithForm extends React.Component {
}));
case "DELETE":
return this.setState(prevState => ({
questions: omit(prevState.questions, value.id)
questions: omit([value.id], prevState.questions)
}));
default:
throw new Error("bad message");
Expand All @@ -68,7 +68,7 @@ export default class QuestionsWithForm extends React.Component {
sortBy(prop("id")),
reverse,
map(question => (
<Editable value={question} onCommit={this.handleCommit}>
<Editable key={question.id} value={question} onCommit={this.handleCommit}>
{editableProps => <QuestionForm {...editableProps} />}
</Editable>
))
Expand Down
1 change: 0 additions & 1 deletion index.js

This file was deleted.

3 changes: 2 additions & 1 deletion stories/index.js
Expand Up @@ -18,13 +18,14 @@ storiesOf("ReactEditable", module)
const FormContainer = composeWithState(QuestionForm);
return (
<FormContainer
value={{
initialValue={{
author: {
firstName: "Alice",
lastName: "B"
},
body:
"I've been doing x, y, and z and it hasn't been working. [Reference](http://example.com) says I should do w but I'm not sure how...",
id: 1,
tags: ["react", "redux"],
title: "How do I connect a component to react redux"
}}
Expand Down

0 comments on commit 5635bce

Please sign in to comment.