The key difference on this question is I want to keep my property referenced inside the object, not destructured.
export interface MapSettings {
up: 'trueNorth' | 'runIn' | 'magneticNorth' | 'user';
rotation?: number;
}
type MapProps = {
settings: MapSettings;
};
export const Map: FunctionComponent<MapProps> = function Map({
settings,
}) {
I want to set a default value for settings.rotation
but I also want to keep it referenced as settings.rotation
because settings has a lot more properties than shown here and I know where the value is coming from.
This is the best answer I can come up with:
export const Map: FunctionComponent<MapProps> = function Map({
settings: { rotation: settingsRotation = 360, ...settings },
}) {
But it doesn't let me reference settings.rotation
with a default value of 360
.