Created
February 19, 2018 14:07
-
-
Save divyanshu013/6623cefefadbaaaa362dea8d8782ae23 to your computer and use it in GitHub Desktop.
Updating onAllData to stream results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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