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

Vue basics MVVM, template syntax and data binding

Table of contents 1. Vue Overview Vue official we...

A brief discussion on how to choose and combine div and table

Page layout has always been my concern since I st...

Public free STUN servers

Public free STUN servers When the SIP terminal us...

Some tips on deep optimization to improve website access speed

<br />The website access speed can directly ...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

Solve the problem of inconsistent front and back end ports of Vue

Vue front and back end ports are inconsistent In ...

Which loop is the fastest in JavaScript?

Knowing which for loop or iterator is right for o...

MySQL stored procedures and common function code analysis

The concept of mysql stored procedure: A set of S...

Solve the group by query problem after upgrading Mysql to 5.7

Find the problem After upgrading MySQL to MySQL 5...

Detailed steps to install RabbitMQ in docker

Table of contents 1. Find the mirror 2. Download ...

JavaScript data visualization: ECharts map making

Table of contents Overview Precautions 1. Usage 2...

Example usage of JavaScript tamper-proof object

Table of contents javascript tamper-proof object ...

MySQL complete collapse: detailed explanation of query filter conditions

Overview In actual business scenario applications...

MySQL 8.0.18 installation and configuration method graphic tutorial

This article records the installation and configu...