Check out example codes for "swift collection view cell size". It will help you in understanding the concepts better.

Code Example 1

extension YourViewController: UICollectionViewDelegateFlowLayout {
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: screenWidth, height: screenWidth)
    }
}

Learn ReactJs, React Native from akashmittal.com