首页 > > 详细

辅导 program、Java设计编程讲解

Managing State in React.js Application
1 Introduction
In this assignment we are going to practice working with application and component level state. State is the collection of
data values stored in the various constants, variables and data structures in an application. Application state is data that
is relevant across the entire application or a significant subset of related components. Component state is data that is
only relevant to a specific component or a small set of related components. If information is relevant across several or
most components, then it should live in the application state. If information is relevant only in one component, or a small
set of related components, then it should live in the component state. For instance, the information about the currently
logged in user could be stored in a profile, e.g., username, first name, last name, role, logged in, etc., and it might be
relevant across the entire application. On the other hand, filling out shipping information might only be relevant while
checking out, but not relevant anywhere else, so shipping information might best be stored in the ShippingScreen or
Checkout components in the component's state. We will be using the Redux state management library to handle
application state, and use React.js state and effect hooks to manage component state.
2 Labs
This section presents React.js examples to program the browser, interact with the user, and generate dynamic HTML. Use
the same project you worked on last assignment. After you work through the examples you will apply the skills while
creating a Kanbas on your own. Using IntelliJ, VS Code, or your favorite IDE, open the project you created in previous
assignments. Include all the work in the Labs section as part of your final deliverable. Do all your work in a new branch
called a4 and deploy it to Netlify to a branch deployment of the same name. TAs will grade the final result of having
completed the whole Labs section.
2.1 Create an Assignment4 Component
To get started, create an Assignment4 component that will host all the exercises in this
assignment. Then import the component into the Labs component created in an earlier
assignment. If not done already, add routes in Labs so that each assignment will appear
in its own screen when you navigate to Labs and then to /a4. Make the Assignment3
component the default element that renders when navigating to http:/ localhost:3000/#/Labs path and map Assignment4
to the /a4 path. You might need to change the lab component route in App.tsx so that all routes after /Labs/* are handled
by the routes declared in the Labs component, e.g., }/>. You might also
want to make Assignment3 the default component by changing the to attribute in the Navigate component in App.tsx, e.g.,
}/>. Use the code snippets below as a guide.
src/Labs/a4/index.tsx src/Nav.tsx src/Labs/index.tsx
import React from "react";
const Assignment4 = () => {
return(
<>

Assignment 4



);
};
export default Assignment4;
import { Link } from "react-router-dom";
function Nav() {
return (
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!