diff --git a/examples/react-router/app/components/recipe.jsx b/examples/react-router/app/components/recipe.jsx index bbe5001..7b1483b 100644 --- a/examples/react-router/app/components/recipe.jsx +++ b/examples/react-router/app/components/recipe.jsx @@ -7,7 +7,7 @@ var RecipeStore = require("../stores/recipe_store.jsx"); class Recipe extends React.Component { constructor() { super(); - this.onDeleteRecipe = this.onDeleteRecipe.bind(this); + this.deleteRecipe = this.deleteRecipe.bind(this); } render() { @@ -31,7 +31,7 @@ class Recipe extends React.Component {

Edit Recipe - {" | "}Delete Recipe + {" | "}Delete Recipe

); @@ -62,15 +62,20 @@ class Recipe extends React.Component { ); } - onDeleteRecipe(e) { + deleteRecipe(e) { if (confirm("Really delete this recipe?")) { - this.props.deleteRecipe(this.props.recipe.id); + this.props.onDeleteRecipe(this.props.recipe.id); } else { e.preventDefault(); } } } +Recipe.propTypes = { + recipe: React.PropTypes.object.isRequired, + onDeleteRecipe: React.PropTypes.func.isRequired +}; + Recipe.contextTypes = { router: React.PropTypes.func }; diff --git a/examples/react-router/app/components/recipe_adder.jsx b/examples/react-router/app/components/recipe_adder.jsx index cb1b1a9..47a7456 100644 --- a/examples/react-router/app/components/recipe_adder.jsx +++ b/examples/react-router/app/components/recipe_adder.jsx @@ -8,8 +8,8 @@ var Recipe = require("../schemas/recipe.jsx"), RecipeForm = require("../forms/recipe_form.jsx"); class RecipeAdder extends React.Component { - constructor() { - super(); + constructor(props) { + super(props); this.onSubmit = this.onSubmit.bind(this); } @@ -48,18 +48,10 @@ class RecipeAdder extends React.Component { ); } } - - deleteRecipe(e) { - if (confirm("Really delete this recipe?")) { - this.props.onDeleteRecipe(this.state.recipe.id); - } else { - e.preventDefault(); - } - } }; RecipeAdder.propTypes = { - onAddRecipe: React.PropTypes.func + onAddRecipe: React.PropTypes.func.isRequired }; RecipeAdder.contextTypes = { diff --git a/examples/react-router/app/components/recipe_editor.jsx b/examples/react-router/app/components/recipe_editor.jsx index 82da243..d68a903 100644 --- a/examples/react-router/app/components/recipe_editor.jsx +++ b/examples/react-router/app/components/recipe_editor.jsx @@ -79,6 +79,12 @@ class RecipeEditor extends React.Component { } }; +RecipeEditor.propTypes = { + recipe: React.PropTypes.object.isRequired, + onEditRecipe: React.PropTypes.func.isRequired, + onDeleteRecipe: React.PropTypes.func.isRequired +}; + RecipeEditor.contextTypes = { router: React.PropTypes.func }; diff --git a/examples/react-router/app/components/recipe_list.jsx b/examples/react-router/app/components/recipe_list.jsx index f04089a..381398e 100644 --- a/examples/react-router/app/components/recipe_list.jsx +++ b/examples/react-router/app/components/recipe_list.jsx @@ -23,6 +23,10 @@ class RecipeList extends React.Component { ); } +} + +RecipeList.propTypes = { + recipes: React.PropTypes.arrayOf(React.PropTypes.object).isRequired }; module.exports = RecipeList; diff --git a/examples/react-router/app/router.jsx b/examples/react-router/app/router.jsx index e179e8c..32dca9e 100644 --- a/examples/react-router/app/router.jsx +++ b/examples/react-router/app/router.jsx @@ -57,12 +57,11 @@ RecipeAdderWrapped = wrap(RecipeAdder, [], (flux) => { // This example shows how you could provide extra context to // the props function (in this case, we want access to the router. RecipeWrapped = wrap(Recipe, ["recipe"], (flux, props, extraContext) => { - console.log(flux.actions); var params = extraContext.router.getCurrentParams(); return { recipe: flux.store("recipe").getRecipe(params.id), - deleteRecipe: (recipeId) => { + onDeleteRecipe: (recipeId) => { flux.actions.recipes.remove(recipeId); } };