We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
之前渲染AppleItem的方式是,在render的return中
<div className="appleList"> { apples.map(apple => { if(!apple.isEaten) return <AppleItem apple={apple} eatApple={actions.eatApple} key={apple.id} /> }) } </div>
这时候都是没问题的,吃苹果的操作都能进行
但是当我将其抽成一个方法的时候,发现吃苹果的操作失效了
getAppleItem(){ return this.props.apples.map(apple => { if(!apple.isEaten){ return <AppleItem apple={apple} eatApple={actions.eatApple} key={apple.id} /> } }); } render(){ ... return ( ... <div className="appleList"> { this.getAppleItem() } </div> ... ) }
测试的发现eatApple失效了了,不知道为什么
The text was updated successfully, but these errors were encountered:
找到失败的原因了,是因为,我在开头引入了actions, 然后再render中也有actions
import actions from '../actions/appleAction';
所以要修改getAppleItem中的actions来源
getAppleItem(){ return this.props.apples.map(apple => { if(!apple.isEaten){ return <AppleItem apple={apple} eatApple={this.props.actions.eatApple} key={apple.id} /> } }); }
Sorry, something went wrong.
No branches or pull requests
之前渲染AppleItem的方式是,在render的return中
但是当我将其抽成一个方法的时候,发现吃苹果的操作失效了
The text was updated successfully, but these errors were encountered: