Javascript/React/Next.js/Ethereum Flashcards
What are the features of React?
1.JSX
2.Components
3.Virtual DOM: React keeps a lightweight representation of the real DOM in the memory, and that is known as the virtual DOM. When the state of an object changes, virtual DOM changes only that object in the real DOM, rather than updating all the objects.
4.One-way data-binding
5.High performance
What is JSX?
JSX is a syntax extension of JavaScript. It is used with React to describe what the user interface should look like. By using JSX, we can write HTML structures in the same file that contains JavaScript code.
Can web browsers read JSX directly?
Web browsers cannot read JSX directly. This is because they are built to only read regular JS objects and JSX is not a regular JavaScript object
For a web browser to read a JSX file, the file needs to be transformed into a regular JavaScript object. For this, we use Babel
What is the virtual DOM?
DOM stands for Document Object Model. The DOM represents an HTML document with a logical tree structure. Each branch of the tree ends in a node, and each node contains objects. React keeps a lightweight representation of the real DOM in the memory, and that is known as the virtual DOM. When the state of an object changes, the virtual DOM changes only that object in the real DOM, rather than updating all the objects. The following are some of the most frequently asked react interview questions.
Why use React instead of other frameworks, like Angular?
Easy creation of dynamic applications
Improved performance
Reusable components
Unidirectional data flow
Dedicated tools for easy debugging
What is the difference between the ES6 and ES5 standards?
class components instead of var, import instead of require
How to create a react app?
Install Node JS, npm install create-react-app
What is an event in React?
An event is an action that a user or system may trigger, such as pressing a key, a mouse click, etc.
React events are named using camelCase, rather than lowercase in HTML.
With JSX, you pass a function as the event handler, rather than a string in HTML.
<Button onPress={lightItUp} />
How do you create an event in React?
alert(“hello this is a popup alert”)
What are synthetic events in React?
Synthetic events combine the response of different browser’s native events into one API, ensuring that the events are consistent across different browsers.
The application is consistent regardless of the browser it is running in. Here, preventDefault is a synthetic event.
Why is there a need for using keys in Lists?
Keys are very important in lists for the following reasons:
A key is a unique identifier and it is used to identify which items have changed, been updated or deleted from the lists
It also helps to determine which components need to be re-rendered instead of re-rendering all the components every time. Therefore, it increases performance, as only the updated components are re-rendered
What are forms in React?
React employs forms to enable users to interact with web applications.
Using forms, users can interact with the application and enter the required information whenever needed. Form contain certain elements, such as text fields, buttons, checkboxes, radio buttons, etc
Forms are used for many different tasks such as user authentication, searching, filtering, indexing, etc
What is an arrow function and how is it used?
An arrow function is a short way of writing a function to React.
It is unnecessary to bind ‘this’ inside the constructor when using an arrow function. This prevents bugs caused by the use of ‘this’ in React callbacks.
What are the components in React?
Components are the building blocks of any React application, and a single app usually consists of multiple components. A component is essentially a piece of the user interface. It splits the user interface into independent, reusable parts that can be processed separately.
There are two types of components in React:Functional Components: These types of components have no state of their own and only contain render methods, and therefore are also called stateless components. They may derive data from other components as props (properties).
Class Components: These types of components can hold and manage their own state and have a separate render method to return JSX on the screen. They are also called Stateful components as they can have a state.
What is State In React?
The state is a built-in React object that is used to contain data or information about the component. The state in a component can change over time, and whenever it changes, the component re-renders.
The change in state can happen as a response to user action or system-generated events. It determines the behavior of the component and how it will render.
How do you implement state?
Use use state in a component, use the context api, create a provider, use a state manager services, use local storage
What are props in React?
Props are short for Properties. It is a React built-in object that stores the value of attributes of a tag and works similarly to HTML attributes.
Props provide a way to pass data from one component to another component. Props are passed to the component in the same way as arguments are passed in a function.
How do you pass props between components?
call the variable of props.variable
What is a higher-order component in React?
A higher-order component acts as a container for other components. This helps to keep components simple and enables re-usability. They are generally used when multiple components have to use a common logic.
Explain the lifecycle methods of components
getInitialState(): This is executed before the creation of the component.
componentDidMount(): Is executed when the component gets rendered and placed on the DOM.
shouldComponentUpdate(): Is invoked when a component determines changes to the DOM and returns a “true” or “false” value based on certain conditions.
componentDidUpdate(): Is invoked immediately after rendering takes place.
componentWillUnmount(): Is invoked immediately before a component is destroyed and unmounted permanently.
State Managers
Zustand, Redux, Etc
Tell me about yourself
I am a JavaScript Developer for Just Add Meta, we create web2 and web3 solutions for our clients. We build web apps, nft sites, landing pages, event sites, ecommerce sites and etc. I work with React, Next.Js and Ethereum tooling. Before this role I was on the developer relations team for alchemy, web3 university I enjoyed helping developers there and building tutorials and working with alchemy tooling. Previous to that role I was a python developer for and education company. I have participated in 2 ETH Global Hackathons.
Why do you want to work at ETH Global
I am a huge fan of ethereum and the goal of ethereum. Permisionless finance, open and transparent finance, soveriegn finance. I really look at ETH Global as an excellent organization in the space and one that is extremely professional and seems to be true to the vision of ethereum.
Can you explain what Next.js is and why would you choose it over other frameworks like Gatsby or Create React App?
Next.js is a React-based framework for server-rendered or statically-exported JavaScript applications. It simplifies the process of building universal or isomorphic apps, which can run both on client and server side.
The key advantage of Next.js over Gatsby or Create React App lies in its versatility. While Gatsby is primarily used for static site generation and Create React App for single-page applications, Next.js supports both these use cases along with server-side rendering. This flexibility allows developers to choose the best approach based on their specific needs.
Moreover, Next.js provides automatic code splitting, simple page routing, built-in CSS support, and hot module replacement out-of-the-box. These features enhance developer experience and productivity. Additionally, it has an active community and strong corporate backing from Vercel, ensuring regular updates and robustness.