Guest User

Untitled

a guest
Feb 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. class Request extends Component {
  2. constructor(props){
  3. super(props);
  4. this.Remove = this.Remove.bind(this)
  5. }
  6.  
  7. componentWillMount(){
  8. firebase.database().ref('/Users/' + AuthID').orderByChild('UserRequests').on("value", function(snapshot) {
  9. snapshot.forEach((child) => {
  10. Name = child.val().Name;
  11. UserID = child.val().UserID;
  12. obj = {key: keyIndex++, Name: Name, ID: UserID};
  13. Requests.push(obj)
  14. });
  15. self.setState({Array: Requests});
  16. });
  17.  
  18. }
  19.  
  20.  
  21. //Need to call map func again as soon as user use Remove func and remove data
  22. RenderUsers = () => {
  23. return this.state.Array.map((Data, i) => (
  24. <View key={i}>
  25. <TouchableHighlight onPress={() => {
  26. this.Remove(Data.ID, Data.Name);
  27. }}>
  28. <Text> Remove </Text>
  29. </TouchableHighlight>
  30. </View>
  31. ))
  32. };
  33.  
  34. Remove = (ID, Name) => {
  35. firebase.database().ref('Users/' + AuthID + '/UserRequests/').child(ID).remove();
  36. //this.RenderUsers();
  37. };
  38.  
  39. render(){
  40. <View>
  41. {this.RenderUsers()}
  42. </View>
  43. }
  44. }
Add Comment
Please, Sign In to add comment