|
所在平台: Udemy |
课程主页: https://www.udemy.com/course/certified-react-js-practice-test-for-personal-development/
课程评论:没有评论
课程名称:React JS 实践测试与个人发展 课程概述:该课程提供了一系列关于 React 的多项选择题(MCQs)和答案,旨在帮助学员为考试、测试及认证做好准备。这些问题来自真实的书面考试和面试,涵盖 UI、DOM、服务、JSX 等基本技术,助力考生顺利通过在线测试。课程通过各个方面教会学员应试所需知识及个人发展重要内容。 1. **学习 React JS 的理由**:ReactJS 提供了优雅的解决方案,适用于前端编程的常见问题,具备快速、可扩展、灵活、强大的特性,并拥有一个迅速增长的开发者社区。 2. **JSX 中的表达式**:在 JSX 中,使用一对大括号可以包含 JavaScript 表达式。JSX 是 JavaScript 的语法扩展,用于创建 DOM 元素。 3. **React 虚拟 DOM**:虚拟 DOM 是实际 DOM 的虚拟表示,能够在应用程序状态改变时提高性能。通过构造虚拟 DOM 树并进行比较,React 能够优化对实际 DOM 的更新,减少性能成本。 4. **React 如何使用虚拟 DOM**:在 React 中,每个 UI 片段都是一个组件,组件的状态变化会更新虚拟 DOM,并通过“diffing”找到需要更新的对象,从而提高性能。 5. **JSX 中的 Props**:可以通过多种方式在 JSX 中指定 props,包括使用 JavaScript 表达式。props 是组件间传递信息的重要机制,支持单向数据流。 6. **React 组件**:学习如何组合组件使应用更易于维护,通过分离组件实现独立更新。 7. **Props 和 PropTypes**:介绍 props 的传递与访问,以及如何使用 PropTypes 验证数据,通过 props 进行父子组件之间的信息传递。 8. **优化 React 应用性能**:讨论如何通过不同方法优化 React 应用的性能,确保只重新渲染受影响的组件,避免资源浪费。 9. **React 中的状态管理**:讨论如何创建带状态的组件,以便处理动态数据。 10. **React Hooks**:介绍 React 16.8 版本引入的新特性,允许在函数组件中使用状态及其他 React 特性,Hooks 提供了一种更简洁的方式来管理组件的状态。 **结论**:通过本课程,学员将学习到 React 的核心概念,并获得实际应用的信心,激励学员继续探索和构建。
Multiple choice questions and answers (MCQs) on React to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as UI, DOM, services, JSX, and more. This quiz will easily prepare anyone to pass their online test. From below you will learn many things that need to help you to pass this exam and your personal development.1. Why we Should Learn React Js?ReactJS presents graceful solutions to some of the front-end programming's most persistent issues. It's fast, scalable, flexible, powerful, and has a robust developer community that's rapidly growing. There's never been a better time to learn React.You'll develop a strong understanding of React's most essential concepts: JSX, class and function components, props, state, lifecycle methods, and hooks. You'll be able to combine these ideas in React's modular programming style.It's not a frameworkAngular or Ember are frameworks where some decisions are already made for you. React is just a library and you need to make all decisions by yourself. It focuses on helping you to build user interfaces using components.2. Expressions in JSXYou can include a JavaScript expression using a pair of curly brackets anywhere within JSX:Nested JSX elementsconst myClasses = ( Sign Up! );For the code to compile, a JSX expression must have exactly one outermost element. In the below block of code the tag is the outermost element.SX is a syntax extension of JavaScript. It's used to create DOM elements that are then rendered in the React DOM.A JavaScript file containing JSX will have to be compiled before it reaches a web browser. The code block shows some example JavaScript code that will need to be compiled.3. React Virtual DOMIf you are using React or learning React, you must have heard of the term "Virtual DOM". Now what is a Virtual DOM, and why does React use it?Virtual DOMThat's where the concept of virtual DOM comes in and performs significantly better than the real DOM. The virtual DOM is only a virtual representation of the DOM. Every time the state of our application changes, the virtual DOM gets updated instead of the real DOM.Well, you may ask " Isn't the virtual DOM doing the same thing as the real DOM, this sounds like double work? How can this be faster than just updating the real DOM?"The answer is virtual DOM is much faster and efficient, here is why.How is Virtual DOM faster?When new elements are added to the UI, a virtual DOM, which is represented as a tree is created. Each element is a node on this tree. If the state of any of these elements changes, a new virtual DOM tree is created. This tree is then compared or "diffed" with the previous virtual DOM tree.Once this is done, the virtual DOM calculates the best possible method to make these changes to the real DOM. This ensures that there are minimal operations on the real DOM. Hence, reducing the performance cost of updating the real DOM.4. How does React use Virtual DOMNow that you have a fair understanding of what a Virtual DOM is, and how it can help with the performance of your app, let's look into how React leverages the virtual DOM.In React every UI piece is a component, and each component has a state. React follows the observable pattern and listens for state changes. When the state of a component changes, React updates the virtual DOM tree. Once the virtual DOM has been updated, React then compares the current version of the virtual DOM with the previous version of the virtual DOM. This process is called "diffing".Once React knows which virtual DOM objects have changed, then React updates only those objects, in the real DOM. This makes the performance far better when compared to manipulating the real DOM directly. This makes React stand as a high-performance JavaScript library.In simple words, you tell React what state you want the UI to be in, and it makes sure that the DOM matches that state. The great benefit here is that as a developer, you would not need to know how the attribute manipulation, event handling or the manual DOM updates happen behind the scenes.All of these details are abstracted away from React developers. All you need to do is update the states of your component as and when needed and React takes care of the rest. This ensures a superior developer experience when using React.5. Props in JSXThere are several different ways to specify props in JSX.JavaScript Expressions as PropsYou can pass any JavaScript expression as a prop, by surrounding it with {}. For example, in this JSX:For MyComponent, the value of props.foo will be 10 because the expression 1 + 2 + 3 + 4 gets evaluated.if statements and for loops are not expressions in JavaScript, so they can't be used in JSX directly. Instead, you can put these in the surrounding code. For example:function NumberDescriber(props) { let description; if (props.number % 2 == 0) { description = even; } else { description = odd; } return {props.number} is an {description} number; }You can learn more about conditional rendering and loops in the corresponding sections.Props Default to "True"If you pass no value for a prop, it defaults to true. These two JSX expressions are equivalent:In general, we don't recommend not passing a value for a prop, because it can be confused with the ES6 object shorthand {foo} which is short for {foo: foo} rather than {foo: true}. This behavior is just there so that it matches the behavior of HTML.6. ReactJS - ComponentsIn this chapter, we will learn how to combine components to make the app easier to maintain. This approach allows you to update and change your components without affecting the rest of the page.Stateless ExampleOur first component in the following example is App. This component is the owner of the Header and Content. We are creating Header and Content separately and just adding it inside the JSX tree in our App component. Only the App component needs to be exported.7. Props And PropTypes In ReactProps and PropTypes are an important mechanism for passing information between React components, and we're going to look into them in great detail here. This tutorial will introduce you to the details about props, passing and accessing props, and passing information to any component using props. However, it's always a good practice to validate the data we are getting through props by using PropTypes. So, you will also learn how to integrate PropTypes in React.Understanding PropsReact allows us to pass information to components using things called props (short for properties). Because React comprises several components, props make it possible to share the same data across the components that need them. It makes use of one-directional data flow (parent-to-child components). However, with a callback function, it's possible to pass props back from a child to a parent component.These data can come in different forms: numbers, strings, arrays, functions, objects, etc. We can pass props to any component, just as we can declare attributes in any HTML tag. Take a look at the code below:In this snippet, we are passing a prop named posts to a component named PostList. This prop has a value of {postsList}. Let's break down how to access and pass data.8. Optimizing Performance In React AppsSince React was introduced, it has transformed the way front-end developers build web applications, and its virtual DOM is famous for effectively rendering components. In this tutorial, we will discuss various methods of optimizing performance in React applications, and also the features of React that we can use to improve performance.During the initial rendering process, React builds a DOM tree of components. So, when data changes in the DOM tree, we want to React to re-render only those components that were affected by the change, skipping the other components in the tree that were not affected.However, React could end up re-rendering all components in the DOM tree, even though not all are affected. This will result in longer loading time, wasted time, and even wasted CPU resources. We need to prevent this from happening. So, this is where we will focus our optimization effort.9. State in ReactUntil now, we discussed only static components with static data passed down the components tree. Often, it's needed to create a stateful component where the state is changing over time.10. React HooksReact HooksHooks are the new feature introduced in the React 16.8 version. It allows you to use state and other React features without writing a class. Hooks are the functions which "hook into" React state and lifecycle features from function components. It does not work inside classes.Hooks are backward-compatible, which means it does not contain any breaking changes. Also, it does not replace your knowledge of React concepts.When to use a HooksIf you write a function component, and then you want to add some state to it, previously you do this by converting it to a class. But, now you can do it by using a Hook inside the existing function component.Rules of HooksHooks are similar to JavaScript functions, but you need to follow these two rules when using them. Hooks rule ensures that all the stateful logic in a component is visible in its source code. These rules are:Only call Hooks at the top levelDo not call Hooks inside loops, conditions, or nested functions. Hooks should always be used at the top level of the React functions. This rule ensures that Hooks are called in the same order each time a components renders.Only call Hooks from React functionsYou cannot call Hooks from regular JavaScript functions. Instead, you can call Hooks from React function components. Hooks can also be called from custom Hooks.ConclusionWe have now learned the Core Concept of ReactJs what we can accomplish. If you feel inspired to build on these examples. Cheers!