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

Summary of Common Problems with Mysql Indexes

Q1: What indexes does the database have? What are...

Example of using CSS3 to customize the style of input multiple-select box

Principle: First hide the input element, then use...

How to implement a password strength detector in react

Table of contents Preface use Component Writing D...

Detailed explanation of CocosCreator optimization DrawCall

Table of contents Preface What is DrawCall How do...

Detailed explanation of MySQL data grouping

Create Group Grouping is established in the GROUP...

React native ScrollView pull down refresh effect

This article shares the specific code of the pull...

Handwritten Vue2.0 data hijacking example

Table of contents 1: Build webpack 2. Data hijack...

A brief talk on responsive design

1. What is responsive design? Responsive design i...

Detailed tutorial on installing Docker and nvidia-docker on Ubuntu 16.04

Table of contents Docker Installation Nvidia-dock...

How to use VUE to call Ali Iconfont library online

Preface Many years ago, I was a newbie on the ser...

HTML form tag tutorial (2):

This tutorial introduces the application of vario...

CSS multi-column layout solution

1. Fixed width + adaptive Expected effect: fixed ...

MySQL limit performance analysis and optimization

1. Conclusion Syntax: limit offset, rows Conclusi...