September 5, 2023
Interview Prep
So, you have a new job interview coming up and you want to be well prepared for any questions that may come up for React. Here are some prep questions for you to consider.
React is a JavaScript library for building user interfaces and web applications. Its an opensource project created by Facebook that allows developers to create scalable, fast, and simple applications. I like it because it makes it easy to create reusable components that I can use in multiple projects.
JSX is a syntax extension for JavaScript that allows you to write HTML within your JavaScript code. I enjoy using JSX because it makes my code more readable and easier to understand. It also allows me to use JavaScript and HTML together, making development faster.
JSX: JSX is a syntax extension to 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, making the code easy to read and understand. It also makes it easy to write component templates.
Components: Components are the building blocks of any React application, and a single app usually consists of multiple components. It splits the user interface into independent, reusable parts that can be processed separately.
Virtual DOM: Reacts one-way data binding keeps everything modular and fast. A unidirectional data flow means that when designing a React application, you often nest child components within parent components. React uses a virtual DOM to represent the actual DOM. This allows it to update the user interface (UI) efficiently without re-rendering the entire page. It’s component based, so developers can create re-usable components. This facilitates developing complex applications because you can independently update each component. It uses a unidirectional data flow, so it flows in one direction
High Performance: React updates only those components that have changed, rather than updating all the components at once. This results in much faster web applications.
Server Side Rendering: Another feature in which React renders pages on the server, making it quick and easy to load pages. This also ensures the pages are SEO friendly.
React components are the building blocks of applications. They are self contained and can be independently updated. Each component has a state which is the data that it uses.
There are two types of components:
React increases efficiency and speeds up the development process. The Virtual DOM improves the performance of applications by only updating the components that have changed instead of re-rendering the entire page. JSX makes it easy to write code and understand the structure of the UI. The component based architecture also eases the development of complex applications. It uses components you can reuse multiple times. You can independently update and reuse these components without affecting the rest of the application.
React uses server side rendering, which makes pages load faster and improves the SEO of an application. This makes it easier for users to find your application. You can easily integrate it with other frameworks such as Next.js, AngularJS, JQuery and Node.js.
React is only a view layer and doesn't provide a full framework. It requires a lot of practice, and it can be challenging to apply it. It uses JSX and inline templating, making the code appear complex and messy for beginners. There are too many components in an application, making it difficult to track them.
The Document Object Model (DOM) represents an HTML document with a logical tree structure. Each branch of the tree ends in a node, and each node contains objects. The virtual document object model represents the actual DOM in memory and is a lightweight representation used by React. When the state of an object changes, the virtual DOM changes only that object in the real DOM, rather than updating all of the objects.
Controlled and uncontrolled components are two different ways of creating forms. You can use controlled components when you want to have complete control over the form and the data entered into it. When you want to allow the user to enter data without having to verify it, you use uncontrolled components. You can use uncontrolled components when you have a simple form that doesn't require much input from the user.
The main difference between state and props is that state is internal to the component and props are external. The state stores data that may change during the lifetime of the component. You can use props to pass data from one component to another. Props are immutable and the component cannot change them, while the component can change the state.