Best Practices for Implementing Simple Jira Projects with React+TS

Best Practices for Implementing Simple Jira Projects with React+TS

A set of projects for training
react+ts
Although the content is less, there are a lot of dry goods, especially the encapsulation of hooks, the understanding of ts generics, and the use of the next level project code: https://gitee.com/fine509/react_jiar

Rendering

insert image description here
insert image description here
insert image description here

These are the three main pages, and some small details

insert image description here
insert image description here
insert image description here
etc.

Some points worth noting (just talking about the general functions, no specific details on how to use them)

insert image description here

Use error boundary processing and getDerivedStateFromError to display the error component instead of hanging up when there is an error somewhere on a page.

Use of useSearchParams

insert image description here
insert image description here

This api can get and set our params here.

Use of react-query

insert image description here
insert image description here
insert image description here

The library is introduced online as a state management library for managing server-side data. It seems to be a bit similar to redux, but it does not require writing many actions and reducers. It supports asynchronous requests, uses keys to uniquely identify data, and has a place similar to a global state management library. It is particularly suitable for certain tables, such as adding, deleting, modifying, and checking, and it also supports optimistic updates. The idea is that, for example, when adding, deleting, modifying, and checking data, you can directly get the original data at the moment of sending the data. Through the logic code you write yourself, you can get the data after adding, deleting, modifying, and checking, and then render it directly to the page. It looks like it has been updated directly, but in fact it is rendered first, and then the background sends the request itself. When it fails, you can also get the original data and re-render it to the page, and then prompt the failure. The last point that particularly bothered me when doing this project was data management.

I first encapsulated a hook myself.

insert image description here

My idea is that a page may need to obtain a lot of data, so it is very troublesome to write Loading by yourself. There are multiple, why can't loading be managed uniformly? Then set data as an object. When using it, you can pass a type to define the type of your data.

insert image description here

Then sendHttp is used to send data

insert image description here

Accepts two parameters. The second parameter is the attribute of data where the current data is to be placed.

The effect of use is

insert image description here
insert image description here
insert image description here

This way, the status of this data can be managed in a unified manner, but later I found that it was very troublesome to use. So I gave up again. It's more comfortable to write natively. Just define the interface directly.

insert image description here

Direct use

insert image description here

Of course, I also thought of using redux, but redux requires writing actions and reducers, which is also very cumbersome.
Recently I heard from a friend that Ahooks' usequest is also good, so I'll try it in my next project.

Finally, the most learned thing from this project is to encapsulate various hooks

Encapsulating redux


insert image description here

Encapsulation request

insert image description here

There is also the study of ts,

If you don't understand an API, just click on the type definition.

insert image description here

If you don't understand something like this, just click in and click one by one.

insert image description here

In this bombardment, you will slowly understand the use of generics.

This is the end of this article about implementing a simple jira project with react+ts. For more relevant react+ts jira project content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • React uses recharts to implement scatter map sample code
  • Using Node to build reactSSR server-side rendering architecture
  • Detailed explanation of setState callback function in React
  • React learning notes on state and use of setState
  • Example code for using Echarts in React components
  • React Native uses Baidu Echarts to display charts sample code

<<:  MySQL 8.0.12 installation steps and basic usage tutorial under Windows

>>:  MySQL 5.7.24 compressed package installation and configuration method graphic tutorial

Recommend

Web Design Tutorial (1): Steps and Overall Layout

<br /> Note: All texts, except those indicat...

Nginx solves cross-domain issues and embeds third-party pages

Table of contents Preface difficulty Cross-domain...

Linux firewall status check method example

How to check the status of Linux firewall 1. Basi...

How to use default values ​​for variables in SASS

Variables defined in SASS, the value set later wi...

Docker uses root to enter the container

First run the docker container Run the command as...

Summary of the use of TypeScript in React projects

Preface This article will focus on the use of Typ...

HTML basics summary recommendation (paragraph)

HTML Paragraph Paragraphs are defined by the <...

MySQL installation tutorial under Linux centos7 environment

Detailed introduction to the steps of installing ...

Docker starts in Exited state

After docker run, the status is always Exited Sol...

mysql5.6.8 source code installation process

Kernel: [root@opop ~]# cat /etc/centos-release Ce...

Introduction to using the MySQL mysqladmin client

Table of contents 1. Check the status of the serv...

Shtml Concise Tutorial

Shtml and asp are similar. In files named shtml, s...