Answers for "react-native array.filter by index arrow function"

1

react-native array.filter by index arrow function

_onHandleRemoveSubmittedPicture = async (i, pictureindex) => {
	console.log('_onHandleRemoveSubmittedPicture: Entering Function');
	console.log('_onHandleRemoveSubmittedPicture: index passed in is: ', pictureindex);
//
// in react-native, removing an item from an array. SelectedStoryPhotos is the array name, remember item is the array item, index is it's position in the arry, picture
// index is the index of the array item you want removed passed in.
// 
	this.setState(state => {
		const selectedStoryPhotos = state.selectedStoryPhotos.filter((item, index) => pictureindex !== index);
		return {selectedStoryPhotos,
		};
	});
	console.log('_onHandleRemoveSubmittedPicture: selectedStoryPhotos after removal of index',pictureindex,'array = ',this.state.selectedStoryPhotos);
}
Posted by: Guest on July-19-2020
1

react-native array.filter by index arrow function

//
// in react-native, removing an item from an array. SelectedStoryPhotos is the array name, remember item is the array item, index is it's position in the arry, picture
// index is the index of the array item you want removed passed in.
// 
	this.setState(state => {
		const selectedStoryPhotos = state.selectedStoryPhotos.filter((item, index) => pictureindex !== index);
		return {selectedStoryPhotos,
		};
	});
Posted by: Guest on July-19-2020
0

filter() array of objects on change react

const handleChange = (e) => {
      const id = hospitalsDetails.filter(obj => obj.hospitalName == e.target.value)
      setCurrentApp({ ...currentApp, [e.target.id]: e.target.value, ["hospitalID"]: id.hospitalID })  
}
Posted by: Guest on June-28-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language