とんたんの技術メモ

注)ただのメモです。

オブジェクト内で、条件によってKEYを付けたり付けなかったりする書き方

React Nativeのお仕事をやっていた時に勉強したのでメモ。

const fetchParams: GetPhotosParamType = {
  first: 50,
  ...(Platform.OS === 'android' ? {} : {groupTypes: 'SavedPhotos'}),
  assetType: 'Photos',
  after: this.state.lastCursor ? this.state.lastCursor : undefined
}