Introduction Flashcards
What is React?
A library for creation of “composable” UI components using Javascript and XML.
What are the main advantages of React?
- Reactive Rendering
- Composable Components
- Abstracted Document model
What is a React component ?
In simpler terms a React component is nothing but the Javascript class, which must have a “render” method which returns the description of “Component’s UI”.
This description will be in JSX format.
Write the general syntax of React component?
class Hello extends React.Component { render () { <h1> Hello World </h1> } }
How React allow us to write “tags” (html/xml”) inside the Javascript code? How browser understands this JSX?
React uses JSX (Javascript extension) for writing the UI components. By this way, we can add tags (xml or html) inside the components.
The browser doesn’t understands this JSX, hence we need a trans compiler which transforms the JSX code into Javascript.
What’s the shortest way to bootstrap a react application?
By using “create-react-app” package.
npm install -g create-react-app
What is npx?
NPX is the package which gets automatically installed, when we install the npm.T he npx is used to run the “npm packages”.
How to use npx to create a react based project?
npx create-react-app todo
What is the package/directory structure created by the create-react-app?
Whenever we create any project using “create-react-app”, it creates the following directory structure:
- public directory
- src directory
- package.json
- .gitignore file
What’s the purpose of “public/index.html” file created by the create-create-app utility?
“index.html” is the main file loaded in user’s browser, whenever a user hits the application.
It contains the “root” element which will contain the entire application.
What’s the purpose of “src/index.js” file created by the create-create-app utility?
This is the main “javascript” file, which is responsible for starting the react application in user’s browser.
This file is also responsible for configuring the react application.
What’s the purpose of “src/app.js” file created by the create-create-app utility?
This is nothing but the react component, which contains the “html” content which will be displayed to the user. It also contains the “javascript” file required for the content.
what is main difference between npm and npx?
npm is used to install packages.
npx is used to execute packages.
In react based development, npx is only used when we need to create a new “project”, rest all other package management is done by “npm”.
How to add “bootstrap” library to you react application?
- Install bootstrap to your project:
npm install bootstrap - Import bootstrap css in index.js
import ‘bootstrap/dist/css/bootstrap.css’
How to start the react application?
npm start