Learn the fundamentals of setting up and building a basic React app using modern tools. This quiz covers project initialization, structure, component creation, and running a local development environment.
Which command can you use in a terminal to verify that Node.js is installed before creating a new React app?
Explanation: The 'node -v' command displays the current version of Node.js, confirming installation. 'npm install' installs packages but does not check for Node.js itself. 'create-react-app check' and 'react-version' are not valid commands for this purpose.
What command sequence is used to create and enter a new React project folder using modern tooling?
Explanation: The correct command is 'npx create-react-app my-react-app' to generate the project, followed by 'cd my-react-app' to move into the directory. The other commands shown are either incorrect, outdated, or do not function as written for modern React projects.
In a newly generated React project, which folder holds the main JavaScript application files you typically edit?
Explanation: The 'src' folder contains the application source files, such as components and style sheets. 'public' stores static files like HTML, 'node_modules' holds dependencies, and 'config' is not a standard folder in basic React setups.
Which of the following represents a simple functional React component that displays a heading?
Explanation: The first option properly defines a React functional component using arrow function syntax, returning JSX. The other options use invalid JavaScript or React syntax and do not represent a correct component definition.
After setting up the app and writing the first component, which command starts the local development server so you can see your app in the browser?
Explanation: 'npm start' launches the development server and opens the app in the browser. 'node index.js' does not work for typical React apps, 'npm build' generates a production build, and 'react-serve' is not a standard command.