Riot: Does Riot has function like React key?

Created on 4 Dec 2017  路  3Comments  路  Source: riot/riot

  1. Describe your issue:

When refference of opts is changed, the component mount again.

For example, there is list loop like this.

<component each={v in datas} data={v}/>

this.datas = [
    { value: 0 },
    { value: 1 }
];

If datas is updated like this, component mounts again.

this.update({ 
    datas: [
        { value: 2 },
        { value: 3 }
    ]
});

I created sample.
https://codepen.io/kwst/pen/qVgedv

The process sequence is here.

  1. push randomize button
  2. this.datas is changed
  3. unmount of component is called
  4. mount of component is called

I expect this.

  1. push randomize button
  2. this.datas is changed
  3. shouldUpdate of component is called
  4. if shouldUpdate return true, component is updated

I think this behavior is key of React. Does Riot has function like React key?
On React, the component doesn't mount again.
https://codepen.io/kwst/pen/Zawgxq

  1. Can you reproduce the issue?

https://codepen.io/kwst/pen/qVgedv

  1. On which browser/OS does the issue appear?

Chrome/Mac os x 10.12.6

  1. Which version of Riot does it affect?

3.7.4

  1. How would you tag this issue?

    • [x] Question
    • [ ] Bug
    • [ ] Discussion
    • [ ] Feature request
    • [ ] Tip
    • [ ] Enhancement
    • [ ] Performance
invalid question

All 3 comments

@GianlucaGuarini Why did you add invalid label? Please tell me the reason.

@SatoshiKawabata because this info is in our doc http://riotjs.com/guide/#key

@GianlucaGuarini Oh key api was icluded from v3.7.x. I didn't know that. My issue is resolved. But it's a little strange that riot's updating is different from React's.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

awei01 picture awei01  路  3Comments

ShiMeiWo picture ShiMeiWo  路  3Comments

vogloblinsky picture vogloblinsky  路  3Comments

cybervaldez picture cybervaldez  路  3Comments

danawoodman picture danawoodman  路  3Comments