React Deck 5 Flashcards
What is a constructor? Is it required?
The constructor is a method that’s automatically called during the creation of an object from a class. … Simply put, the constructor aids in constructing things. In React, the constructor is no different. It can be used to bind event handlers to the component and/or initializing the local state of the component.
If you don’t initialize state and bind methods, the constructor is not required for your component.
What is the difference of calling a promise and using a .then
vs using await
?
The fundamental difference between await and vanilla promises is that await X() suspends execution of the current function, while promise. then(X) continues execution of the current function after adding the X call to the callback chain. In the context of stack traces, this difference is pretty significant.
Which of these are required properties of the object in your package.json file?
The required properties in the package.json file is
“name”
“version”
What is NPM/Yarn?
The name npm (Node Package Manager) stems from when npm first was created as a package manager for Node.js.
All npm packages are defined in files called package.json.
The content of package.json must be written in JSON.
At least two fields must be present in the definition file: name and version.
Yarn is a new package manager that replaces the existing workflow for the npm client or other package managers while remaining compatible with the npm registry. It has the same feature set as existing workflows while operating faster, more securely, and more reliably
Can different versions of the same package be used in the same application?
Yes they can, but you should stay away from and stay on the same versions.
How come when you declare a variable in any js or jsx file outside of any class, object or function, it’s not really global to all other files, componets?
its a variable that lives in the file that you’re not exporting.
Have to export variable