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

JSX中的列表常量不能与state中的成员重名 #411

Closed
zacksleo opened this issue Aug 1, 2018 · 6 comments
Closed

JSX中的列表常量不能与state中的成员重名 #411

zacksleo opened this issue Aug 1, 2018 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@zacksleo
Copy link
Contributor

zacksleo commented Aug 1, 2018

问题描述

在render方法中,使用 const 声明一个列表变量,然后在后面使用,该变量与state中的成员重名时,列表不会渲染

复现步骤

  constructor(props: any) {
    super(props);
    this.state = {
      packages: [{"id":5039,"name":"旧金山","packages":[{"id":1289,"name":"接站名称:SFO Airport Hotel ,Courtyard by Marriott。时间:7:00am。地点:1050 Bayhill Dr, San Bruno, CA 94066","price":0},{"id":1290,"name":"接站名称:San Francisco,旧金山联合广场。时间:7:30am。地点:291 Geary St, San Francisco, CA 94102","price":0},{"id":1291,"name":"接站名称:Oakland,工商银行。时间:8:00am。地点:401 9th St, Oakland, CA 94607","price":0},{"id":1292,"name":"接站名称:Cupertino,永和超市。时间:7:15am。地点:10122 Bandley Dr, Cupertino, CA 95014","price":0},{"id":1293,"name":"接站名称:Milpitas,大华99超市。时间:8:00am。地点:338 Barber Lane Milpitas, CA 95035","price":0},{"id":1294,"name":"接站名称:Hayward,lucky超市。时间:8:30am。地点:22555 Mission Blvd, Hayward, CA 94541","price":0}]}]
    };
  }

  render() {
    const packages = this.state.packages.map((pkg) => {
      return (
        <View key={pkg.id}>
          <View><Text>{pkg.name}</Text></View>
          <Picker mode="selector" range={pkg.packages} rangeKey="name">
            <View>当前选择</View>
          </Picker>
        </View>
      );
    });
  return (
  {packages}
);

期望行为

Picker能正常显示

报错信息

没有显示任何信息, 将 const packages 改成其他名称就可以正常显示了

系统信息

  • 操作系统: mac
  • Taro 版本 v0.0.73
  • Node.js 版本 v8.11.1

补充信息

编译时可能需要对变量重新命名,或者添加一条 eslint 规则?

@yuche yuche self-assigned this Aug 2, 2018
@zacksleo
Copy link
Contributor Author

zacksleo commented Aug 5, 2018

#318 问题的重现

@luckyadam luckyadam added the bug Something isn't working label Aug 6, 2018
@stale
Copy link

stale bot commented Oct 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Oct 24, 2018
@zacksleo
Copy link
Contributor Author

解决了没

@stale stale bot removed the wontfix label Oct 24, 2018
@zaaack
Copy link
Contributor

zaaack commented Nov 13, 2018

这个 bug 有更新吗?

@yuche
Copy link
Contributor

yuche commented Nov 13, 2018

没有,我们可能会写一条 eslint 插件禁用掉这个写法

@zacksleo
Copy link
Contributor Author

good job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants