Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Request extends Component {
- constructor(props){
- super(props);
- this.Remove = this.Remove.bind(this)
- }
- componentWillMount(){
- firebase.database().ref('/Users/' + AuthID').orderByChild('UserRequests').on("value", function(snapshot) {
- snapshot.forEach((child) => {
- Name = child.val().Name;
- UserID = child.val().UserID;
- obj = {key: keyIndex++, Name: Name, ID: UserID};
- Requests.push(obj)
- });
- self.setState({Array: Requests});
- });
- }
- //Need to call map func again as soon as user use Remove func and remove data
- RenderUsers = () => {
- return this.state.Array.map((Data, i) => (
- <View key={i}>
- <TouchableHighlight onPress={() => {
- this.Remove(Data.ID, Data.Name);
- }}>
- <Text> Remove </Text>
- </TouchableHighlight>
- </View>
- ))
- };
- Remove = (ID, Name) => {
- firebase.database().ref('Users/' + AuthID + '/UserRequests/').child(ID).remove();
- //this.RenderUsers();
- };
- render(){
- <View>
- {this.RenderUsers()}
- </View>
- }
- }
Add Comment
Please, Sign In to add comment