react basics coursera week 1 quiz answers

Knowledge check: React components and where they live

1. When adding a component name after the function keyword, it should be named using:

  • lowerCamelCase
  • kebab-cased
  • PascalCase (UpperCamelCase)

2. There are two components at the root of the src folder: Example and App. To import the Example component into the App component, you should use the following syntax:

  • import “Example”;
  • import Example from “./Example”;
  • import Example;

3. True or False: You can omit the “./” from the import statement, when both the exported and the imported components are in the same folder.

  • True
  • False

4. Pick the correct syntax needed to export a component so that it can be imported.

  • export standard Example;
  • export default;
  • export example;
  • export default Example;

5. You've imported the Example component into the App component. What will the following syntax do: return ( ) ?

  • It will throw an error.
  • It will render the App component on the screen.
  • It will show a warning.
  • It will render the Example component on the screen.

Module Quiz

6. Why is React using the concept of components?

  • It improves the styling of your pages.
  • It allows you to build more modular apps.
  • It allows the browser to render your pages faster.
  • It helps accessibility readers for people who are visually impaired.

7. What is the absolute minimum code that a component must have to be able to show something on a screen when rendered?

  • A named function declaration and a return statement with at least a single element with some text inside of it.
  • A named function declaration.
  • A named function declaration and an array of items inside of the function’s body.
  • A named function declaration and some variables in the function’s body.

8. What are the benefits of using props?

  • Props allow developers to write custom HTML tags.
  • Props allow children components to update the values of each prop independent from their parent component.
  • Props allow parent components to pass data to children components.

Shuffle Q/A 1

9. You are tasked with building a web layout using React. The layout should have a header, a footer, and three products showing various data in the main part of the page. Choose the preferred component structure.

  • It should have a separate component for each link, paragraph, heading, etc.
  • It should all fit into a single component named App component.
  • It should have the following components: Header, Main, Product, Footer (with the Product component being imported into Main and rendered three times).

10. Which of the following keywords can you usually find in a React component?

  • module, function, prop, exported, default
  • modular, expression, prop, default
  • function, props, return, export, default
  • function, props, export, import, contain

Leave a Reply