0
は、だから私は基本的に、私は問題を抱えています唯一のものは、パネルの崩壊状態を追跡することであるFCCのRecipeBox ProjectReduxのが反応-ブートストラップ折りたたみパネルの問題
の1を終えました。
つまり、アプリの状態(レシピの追加、削除、編集のいずれか)を変更するたびに、ページが再描画され、すべてのパネルがそれをアンコレラートします。
私はReact-Bootstrap Documentを見ましたが、わかりません。
私の現在のコードは動作しません各レシピ項目の状態を適用する
のsrc /コンテナ/ recipebox
class RecipeBox extends Component {
constructor(props){
super(props);
this.state = {open: false}
this.renderRecipeList = this.renderRecipeList.bind(this)
this.handleRecipeNameChange = this.handleRecipeNameChange.bind(this)
this.handleUserIngredientsChange = this.handleUserIngredientsChange.bind(this)
}
handleRecipeNameChange(event){
this.setState({recipeName: event.target.value})
}
handleUserIngredientsChange(event){
this.setState({userIngredients: event.target.value})
}
renderRecipeList(recipeItem, index){
const recipe = recipeItem.recipe;
const ingredients = recipeItem.ingredients;
const recipeID = recipeItem.id;
const id = shortid.generate();
return(
<div key={id}>
<Panel
collapsible
onClick={()=> this.setState({ open: !this.state.open })}
eventKey={index}
header={<h3>{recipe}</h3>}>
<ListGroup >
<ListGroupItem header="Ingredients"></ListGroupItem>
{ingredients.map(function(ingredient,index){
return <ListGroupItem key={index}>{ingredient}</ListGroupItem>;
})}
<ListGroupItem>
<Button
onClick={() => this.props.deleteRecipe(recipeItem)}
bsStyle="danger">Delete
</Button>
<Edit
recipeName={recipe}
userIngredients={ingredients}
recipeID={recipeID}
/>
</ListGroupItem>
</ListGroup>
</Panel>
</div>
)
}
render(){
const self = this;
return(
<div className="container">
<div className='panel-group'>
{this.props.recipeList.map(self.renderRecipeList)}
</div>
</div>
)
}
}
function mapStateToProps(state) {
return {
recipeList : state.recipeState
};
}
function mapDispatchToProps(dispatch){
return bindActionCreators({deleteRecipe : deleteRecipe, editRecipe : editRecipe}, dispatch)
}
export default connect(mapStateToProps,mapDispatchToProps)(RecipeBox);