download:React17+React Hook+TS4 Best practices mimic Jira enterprise projects

React17 + React Hook + TypeScript4 has become synonymous with quality assurance for large React projects and is a must-have technology for good React developers in 2021. This course will take you through a powerful task management project to master best practices and improve development efficiency, quality and technical capabilities in an all-round way.

React based technical requirements

React 17.0.1 / TypeScript 4.0.5 / react-router: 6.0.0 / create-react-app 4.0.1 react-query: 1.0.0 / emotion: 10.0.35 / cypress: 6.1.0 / jest: 26.6.3 func AsyncAdd(run func() error) {//TODO: Go run()} func GetInstance(CTX context. context, ID uint64) (string, error) { data,err := GetFromRedis(ctx,id) if err ! = nil && err ! Nil{return “”, err} if err == redis.Nil{data,err = GetFromDB(CTX,id) if err! = nil{ return “”, err } AsyncAdd(func() error{ return UpdateCache(ctx,id,data) }) } return data,nil } func GetFromRedis(ctx context.Context,id uint64) (string,error) { // TODO: Return “”,nil} func GetFromDB(CTX context. context,id uint64) (string,error) {// TODO: Return “”,nil} func UpdateCache(CTX context. context,id interface{},data string) error {// TODO: Return nil} func main() {CTX,cancel := context.withtimeout (context.background (), 3 * time.Second) defer cancel() _,err := GetInstance(ctx,2021) if err ! = nil{return}} parse let’s just parse, what does this piece of code do? In fact, it is very simple. If we want to get a piece of information, we will first get it from the cache. If we can’t get it from the cache, we will get it from DB. Isn’t the whole design great, but in practice, asynchronous cache updates have never been successful?

The recipe for failure lies in this code:

AsyncAdd(func() error{return UpdateCache(CTX,id,data)}) AsyncAdd(func() error{return UpdateCache(CTX,id,data)})

AsyncAdd(func() error{

ctxAsync,cancel := context.WithTimeout(context.Background(),3 * time.Second)

defer cancel()

return UpdateCache(ctxAsync,id,data)

})