Skip to content
New issue

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

微信小程序 子组件使用父组件props的属性,map渲染会出现数据错乱 #5159

Closed
vscing opened this issue Dec 23, 2019 · 9 comments
Assignees

Comments

@vscing
Copy link

vscing commented Dec 23, 2019

问题描述

微信小程序 子组件使用父组件props的属性,map渲染会出现数据错乱

复现步骤

image

  1. 父组件传递list属性和onChangList方法
  2. 初次list渲染正常, 点击子组件触发父组件onChangList方法,改变list数据
  3. 子组件打印正常,map渲染开始出错
render() {
    const { list, onChangList} = this.props;
    console.log(list)
    return (
            <View>
                {
                    list.map((item, index)=>
                        <View key={index} onClick={onChangList.bind(this, item.id)}>
                            {item}
                        </View>
                    )
                }
            </View>
    )
}

期望行为

map渲染正常

报错信息

系统信息

补充信息

如果您有功能上的建议,可以提到 FeatHub

使用上的问题,欢迎在「Taro 社区」一起交流

@taro-bot
Copy link

taro-bot bot commented Dec 23, 2019

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Dec 23, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@vscing
Copy link
Author

vscing commented Dec 23, 2019

放在父组件里面正常

@Chen-jj
Copy link
Contributor

Chen-jj commented Dec 24, 2019

@vscing 什么版本

@vscing
Copy link
Author

vscing commented Dec 24, 2019

@vscing什么版本

"@tarojs/taro": "1.3.12",

@JerryChan31
Copy link

key={index} 改成其他的试试?

@vscing
Copy link
Author

vscing commented Dec 24, 2019

key={index} 改成其他的试试?
试过,不行

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 13, 2020

@JerryChan31 请提供完整可复现代码

@taro-bot
Copy link

taro-bot bot commented Jan 13, 2020

Hello~

您的问题所提供的信息不足,我们无法定位到具体的问题。如果有空的话还请拔冗提供更具体的信息,否则这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@taro-bot taro-bot bot removed the to be closed label Jan 28, 2020
@taro-bot taro-bot bot closed this as completed Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants