How to use React Native ListView with MobX?

I am trying to populate a ListView in a native reaction using a MobX observable array as follows:

constructor(props) {
        super(props)
        var dataSource = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
        let dogs = props.store.dogs;
        this.state = { dogs: dogs, dataSource: dataSource };
    }

    render() {

        var dogs = this.state.dogs;
        var dataSource = this.state.dataSource.cloneWithRows(dogs);

        return <ListView
            dataSource={dataSource}
            renderRow={this.renderRow}
            />
    }

But when you run the code, renderRow () is never called. He, like the cloneWithRows () method, did not know how to clone strings.

Has anyone succeeded in doing this? (And also make him behave so that when the name of the dog in the list of dogs changes, the cell in the list will be displayed again)

Update: more details here https://github.com/mobxjs/mobx/issues/476

+4
source share
1 answer

, (lol) dogs.slice(), ListView . , , renderRow, , .

, render, ; , , , .

: https://github.com/mobxjs/mobx/issues/476

+1

Source: https://habr.com/ru/post/1651963/


All Articles