0

I have an object which includes string with dot "journey.hintText.journeyTags" as the key. (returned by api response i cannot modify). I would like to destruct content object like const {journey.hintText.journeyTags} = content, but it throws error. Please let me know how I can destruct content object, thanks a lot.

const content = {journey.hintText.journeyTags: 'Please select a tag'}
Yang Wang
  • 580
  • 4
  • 14

1 Answers1

2

You can use computed properties, but you should provide the name like this const { ['journey.hintText.journeyTags']: journeyTags } = content

Denis Malykhin
  • 349
  • 1
  • 6