0

I am building a react application that gets data from Firestore. I am stuck with getting values from a Key: value pair in which the key is more than one word.

I create my component like so:

const MyComponent = ({theData}) => {
return (
    <div>
      <p>theData.name</p>
      <p>theData.Special Pass</p>
    </div>
)
}

The first one with the "Name" works fine and I can view the value. I am stuck on the second one. I have tried:

theData.["Special Pass"}
theData.{"Special Pass"}

and several other variations without success. Please assist.

Thanks

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sky Lurk
  • 417
  • 1
  • 3
  • 13

2 Answers2

2

Try theData["Special Pass"]

maya_nk99
  • 502
  • 3
  • 5
1
const MyComponent = ({theData}) => {
return (
    <div>
        <p>{theData.name}</p>
        <p>{theData["Special Pass"]}</p>
    </div>
) }
w35l3y
  • 8,613
  • 3
  • 39
  • 51