Skip to content

Instantly share code, notes, and snippets.

@divyanshu013
Created February 19, 2018 14:07
Show Gist options
  • Save divyanshu013/6623cefefadbaaaa362dea8d8782ae23 to your computer and use it in GitHub Desktop.
Save divyanshu013/6623cefefadbaaaa362dea8d8782ae23 to your computer and use it in GitHub Desktop.
Updating onAllData to stream results
import Utils from '../utils';
...
export default class TodosContainer extends React.Component {
...
onAllData = (todos, streamData) => {
// merge streaming todos data along with current todos
const todosData = Utils.mergeTodos(todos, streamData);
// filter data based on "screen": [All | Active | Completed]
const filteredData = this.filterTodosData(todosData);
return (
<FlatList
style={{ width: '100%', top: 15 }}
data={filteredData}
keyExtractor={item => item._id}
renderItem={({ item: todo }) => (
<TodoItem todo={todo} onUpdate={this.api.update} onDelete={this.api.destroy} />
)}
/>
);
};
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment