0
Interface Button{
buttonTitle: {
    addAdmin?: string;
  confirmAdmin?: string;
  }
}

How I can define type for buttonTitle?

2 Answers 2

1

Your question does not have anything to do with React. It's a TypeScript question.

Just define another interface (or type if that's your preference) and use it:

interface ButtonTitle {
  addAdmin?: string;
  confirmAdmin?: string;
}

interface Button {
  buttonTitle: ButtonTitle;
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use enum type for this.

enum ButtonTitle {
  addAdmin = "ADDADMIN",
  confirmAdmin = "CONFIRMADMIN",
}

Interface Button {
  buttonTitle: ButtonTitle
}

You can read more about enums here

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.