I have two components. e.g. Dashboard and Card
Dashboard:
render() {
const elements = this.props.cards.map((card, key) => {
return (
<Card item={card} onSave={this.onCardSave}>
)
})
}
Card
render() {
return (
<div class="card">
<input type="checkbox" checked={this.state.item.checked} onChange={this.onChangeChecked} />
{ this.someCondition() && <input type="text" value={this.state.item.name} onChange={this.onChangeName} />}
</div>
)
}
So text field visibility is depending on some condition. For example:
function someCondition () {
return this.state.item.checked
}
!! This logic is only for Card instance
So where is the best place to store this logic?
Inside Card? (like my code)
Inside Dashboard? (pass all events in props for example)
If you can provide me some article on this theme, I would be very grateful