Check out example codes for "deselect all cell in collectionview". It will help you in understanding the concepts better.

Code Example 1

extension UICollectionView {

    func deselectAllItems(animated: Bool) {
        guard let selectedItems = indexPathsForSelectedItems else { return }
        for indexPath in selectedItems { deselectItem(at: indexPath, animated: animated) }
    }
}

Learn ReactJs, React Native from akashmittal.com