☀ ️ preface

You can find a lot of Code Review practices, Code Review procedures, how to Code Review, etc. It seems that there are not many actual review records, and I happen to be lucky enough to be the leader of the front-end team, so I usually go to secretly see what excellent code everyone has written. So today by the younger brother I, to share with you, small factory front line usually write code 😸

The author’s ability is limited, the comments inside may not be very correct, just make a record, throw a brick to attract jade, for learning reference ~

The last article received a lot of students’ likes and comments, so today I will continue to bring you the second wave of sharing, I hope to bring you thinking and harvest ~

This article is the second in the series. The previous one is here: juejin.cn/post/705257…

💻 Talk is cheap. Show me the code!

Project Background:

  • The react 16.8 +
  • antd@4

Use native JS to get the DOM node without using a variable to maintain the ID value

Facilitate subsequent maintenance

Thinking curing

The student may have forgotten that the format function entry can be changed 😂

Logic is not abstract enough

Simple problems complicated, this pile of && is not to see the head big.

The file name is different from the actual content

Improper naming

Small humps, all caps, big lines.

The granularity of state is too fine

Avoid a component with n lines of useState

Avoid modifying object values directly. React requires immutable data

Website: zh-hans.reactjs.org/tutorial/tu…

Not familiar with Antd component apis

If you want to change the internal style of the Popover component, you should have an extra div on top of it

ant-design popover api: overlayClassName

The scrolling height of the Table is not adaptive

Scroll ={{y: ‘calc(100vh – distance from top px)’}}

👋 is at the end

This article is shared here, the overall content is a little scattered, for the students who have no foundation may not be too friendly, but if you feel something gained after reading, you can leave a comment like! Later, I will take time to record and strive for a series of articles ~ / flower 🎉🎉🎉