React Flashcards
What is React?
A JavaScript library used in web development to build interactive elements on a website using UI components.
What makes React so great?
With React, we can setup data separately, iterate over the data, return the elements we want to render in the browser, and inject data dynamically.
Component
Independent chunks of user interfaces. There is at least one. Created with a function.
node_modules (folder)
contains dependencies the project is using. Also contains sub-dependencies.
public (folder)
where the index.html is that displays the webpage.
src (folder)
the brain of the application. Where all the work is performed in the application. src/index.js is the JavaScript entry point.
.gitignore (file)
specifies which files source control (Git) should ignore
package.json (file)
every Node.js project has this file and it contains information about the project. For example, a list of dependencies and scripts.
package-lock.json (file)
a snapshot of the entire dependency tree. Shows the main dependencies the project is using and the scripts. This shows all the dependency packages with specific versions so when someone uses this project, they’ll have the exact dependency tree with all the same dependency versions.
JSX (JavaScript XML)
A syntax extension to JavaScript which allows you to write HTML in React. JSX converts HTML tags into react elements. So you do not have to use HTML methods such as createElement() and/or appendChild(). You are not required to use JSX, but it makes it easier to write React applications. You can only have one parent element in JSX.
Initial Render
In a React app, the initial render is the first time the component tree is rendered to the DOM. This happens when the application first loads, or when the root component is rendered. This is known as “mounting” the components. When the component us unmounted and re-mounted, it will also be initially rendered.
re-render
This happens when the component’s state or props change and the component needs to be updated in the DOM to reflect the changes. Re-renders also happen when the parent element re-renders. React uses a virtual DOM to optimize the process of updating the DOM so only the necessary changes are made.
<React.Fragment>
</React.Fragment>
lets you group a list of children without adding extra nodes to the DOM. You won’t see this tag in inspect element. The shorthand for this is <> </>
className (attribute)
attribute that is used since “class=’xxx’ “ will not work.
react dev tools (chrome extension)
You can see the component tree when opening inspect element > Components (tab)
import “./xxxx.css” (code)
this allows you to import a css file into the .js file. You do not have to do this with .js files.