Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cooperka/react-native-immutable-list-view
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: cooperka/react-native-immutable-list-view
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: render-audit
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Nov 19, 2016

  1. Copy the full SHA
    53c1514 View commit details
Showing with 76 additions and 2 deletions.
  1. +33 −1 example/src/App.js
  2. +39 −0 example/src/listData.js
  3. +4 −1 src/ImmutableListView.js
34 changes: 33 additions & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
@@ -5,19 +5,51 @@ import { Text, View } from 'react-native';
import ImmutableListView from 'react-native-immutable-list-view/src/ImmutableListView';

import style from './styles';
import listData from './listData';
import mockData, { sameData, differentSections, differentRows } from './listData';

class App extends Component {

state = {
listData: mockData,
};

componentDidMount() {
const delay = 1000;

setTimeout(() => {
console.log('--- Setting sameData');
this.setState({ listData: sameData });
}, 1 * delay);

setTimeout(() => {
console.log('--- Setting differentSections');
this.setState({ listData: differentSections });
}, 2 * delay);

setTimeout(() => {
console.log('--- Setting sameData');
this.setState({ listData: sameData });
}, 3 * delay);

setTimeout(() => {
console.log('--- Setting differentRows');
this.setState({ listData: differentRows });
}, 4 * delay);
}

renderRow(rowData) {
console.log('> renderRow\t\t', rowData);
return <Text style={style.row}>{JSON.stringify(rowData)}</Text>;
}

renderSectionHeader(sectionData, category) {
console.log('> renderHeader\t', category);
return <Text style={style.header}>{category}</Text>;
}

render() {
const { listData } = this.state;

return (
<View style={style.container}>
<Text style={style.welcome}>
39 changes: 39 additions & 0 deletions example/src/listData.js
Original file line number Diff line number Diff line change
@@ -11,4 +11,43 @@ const data = Immutable.fromJS({
],
});

const sameData = Immutable.fromJS({
'Section A': [
'foo',
'bar',
],
'Section B': [
'fizz',
'buzz',
],
});

const differentSections = Immutable.fromJS({
'Section C': [
'foo',
'bar',
],
'Section D': [
'fizz',
'buzz',
],
});

const differentRows = Immutable.fromJS({
'Section A': [
'baz',
'qux',
],
'Section B': [
'fizz',
'buzz',
],
});

export {
sameData,
differentSections,
differentRows,
};

export default data;
5 changes: 4 additions & 1 deletion src/ImmutableListView.js
Original file line number Diff line number Diff line change
@@ -94,7 +94,10 @@ class ImmutableListView extends PureComponent {

state = {
dataSource: new ListView.DataSource({
rowHasChanged: (prevRowData, nextRowData) => !Immutable.is(prevRowData, nextRowData),
rowHasChanged: (r1, r2) => {
console.log('? rowHasChanged ?\t\t', r1, Immutable.is(r1, r2) ? '==' : '!=', r2);
return !Immutable.is(r1, r2);
},

getRowData: (dataBlob, sectionID, rowID) => {
const rowData = getValueFromKey(sectionID, dataBlob);