Explore the essential steps and tools involved in initializing a React project without using boilerplate tools. Learn about key packages, configuration practices, and the basic logic behind rendering with React.
Which two packages must be included to render a React application in the browser?
Explanation: React and ReactDOM are essential for rendering a React application in the browser; React contains the core API, while ReactDOM handles interacting with the DOM. Parcel and Babel are used for bundling and transpiling, not rendering. Webpack is another bundler option, but not required specifically for rendering. Node and Express are backend technologies, not related to rendering React on the frontend.
What tool is typically used to transpile JSX code into browser-compatible JavaScript when setting up a React project from scratch?
Explanation: Babel is the standard tool for converting JSX into regular JavaScript that browsers can interpret. ESLint is for code linting, Prettier is for code formatting, and Sass is used for styling, none of which are responsible for transpiling JSX.
Which of the following tools can be used as a JavaScript bundler to manage project files and dependencies when starting a React project manually?
Explanation: Parcel is a bundler that handles compiling and bundling JavaScript, including React files, for development and production. ReactDOM is for rendering, not bundling. SQL is a database language and unrelated to bundling. Gatsby is a React-based framework, not a bundler.
What is the primary purpose of running 'npm init' at the start of a new React project?
Explanation: 'npm init' generates a package.json file, which keeps track of the project's dependencies and scripts. It doesn't render components or install React. Setting up webpack configuration is a separate process, not handled by this command.
How is a root component typically rendered into the DOM in a manually set up React project?
Explanation: ReactDOM.render is used to insert the root React component into a specified DOM element in the page. Importing in index.css or package.json scripts does not render a component. HTML meta tags do not play a role in rendering React components.