0

I'm getting an odd error with object inside an object in React Native. I set some state variables in my constructor:

this.state = {
   payAmount: 0,
   selectedPaymentMethod: 0,
   btnDisabled: true,
   cardDetails: {
     cardName: '',
     cardNumber: '',
     cardCVV: '',
     cardExpiration: '',
     cardPostalCode: ''
   }
};

Then, when I try to access "cardDetails", it returns Can't find variable: cardName

Code:

const data = { cardName, cardNumber, cardCVV, cardExpiration, cardPostalCode } = this.state.cardDetails;

Can't I use object inside an object in react native?

Thank you!

1
  • can u past the whole code Commented Dec 26, 2019 at 23:06

1 Answer 1

1
const { cardName, cardNumber, cardCVV, cardExpiration, cardPostalCode } = this.state.cardDetails;

and yes, You can create object inside object.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.