Questions

Answer the following questions, based on what we have just learned:

  1. During development, what are the TSLint settings for allowing debugger statements and logging to the console?
  2. In JSX, how can we display a button with a label from a prop called buttonLabel in a class component?
  3. How can we make the buttonLabel prop optional, and default to Do It?
  1. In JSX, how can we display this button only if the doItVisible state is true? (Assume we already have a state type declared containing doItVisibleand it has already been initialized in the constructor.)
  2. How would we create a click handler for this button?
  3. We have a state type declared containing doItDisabled. It has also been initialized in the constructor. How would we set this state to disable the Do it button after we click it?
  4. If the button is clicked when it is in a disabled state, is the click handler still executed?
  5. What life cycle method would we use in a class component to add event handlers to a non-React web component living in our React component?
  6. Which life cycle method would we use to remove this event handler?
  7. We have a function component called Counter. It needs to contain a piece of state called count, and a function to update it called setCount. How can we define this state and default the initial count to 10?
  8. In the preceding Counter component, we have a decrement function that needs to reduce count by 1
const decrement = () => {
// TODO - reduce count by 1
};

How can this be implemented?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.105.239