- During development, what are the TSLint settings for allowing debugger statements and logging to the console?
"rules": {
"no-debugger": false,
"no-console": false,
},
- In JSX, how can we display a button with a label from a prop called buttonLabel in a class component?
<button>{this.props.buttonLabel}</button>
- How can we make the buttonLabel prop optional and default to Do It?
Use a ? before the type annotation in the interface for the props:
interface IProps {
buttonLabel?: string
}
Implement a static defaultProps object at the top of the class component:
public static defaultProps = {
buttonLabel: "Do it"
};
- In JSX, how can we display the preceding button only if the state called doItVisible is true? Assume we already have a state type declared containing doItVisible...