I recently came across this strange JavaScript code:
export type ImageSource = {
id: string,
URI: string,
thumbnail: string,
title: ?string,
description: ?string
}
type Props = {
images: Array<ImageSource>,
onPressImage?: Function,
topMargin?: number,
closeText?: string,
infoTitleStyles?: Animated.View.style,
infoDescriptionStyles?: Animated.View.style,
enableTilt?: boolean
}
If I understand it correctly, string is a data type, but can someone explain, what is the difference between string and ?string.
Also, what does the following line of code mean:
topMargin?: number,
I've got it from a sample react-native app, I'm assuming, it signifies an optional property, but I can't find any explanation when googling for it.
numberorundefinedtypescriptlang.org/docs/handbook/…