Knowledge check: Events and errors - React Basic

Knowledge check: Events and errors - React Basic

  1. When handling a click event in react, you should use the following attribute:

    • Onclick

    • OnClick

    • on-click

    • onClick

  2. Inside a JSX element, you can assign a JSX expression to the onClick handler to handle a click in React.

    • False

    • True

  3. You can place an opening and a closing parenthesis after the name of the event-handling function that you assign to the onClick attribute.

    • True

    • False

  4. The try...catch syntax can be used in React in certain cases.

    • True

    • False

  5. Choose the valid example of an onclick event handler.

    • <button onclick={handleClick}>Click me</button>

    • <button onClick={handleClick()}>Click me</button>

    • <button on-click=”handleClick”>Click me</button>

    • <button onClick={handleClick}>Click me</button>