Member-only story

Performance optimization in React apps

Beck Moulton
6 min readMay 1, 2024

--

Tips

  • Quickly jump to a specific line in the file. In vim, simply enter : < line number >, such as : 25and press Enter to quickly jump to line 25.
  • VSCode multi-cursor editing. Press Ctrl(Cmd) + Alt(Option) + up or down arrow keys to create a new cursor above/below to edit on multiple lines at the same time.
  • JavaScript deep copy object. Use JSON.parse (JSON.stringify (obj))to make a simple deep copy of the object obj.
  • Using git add -p can selectively temporarily store a portion of code changes, achieving refined commits, with each commit containing only one logical change.

Article recommendation

Performance optimization of immer 2

Immer is a JavaScript library for processing immutable data. Its performance is excellent, thanks to its “ability to recognize states without substantial changes and return to the original state, avoiding unnecessary re-rendering”.

If you want to add a large amount of data to the state tree, you can first perform a freeze operation.

import { freeze } from "immer";data = freeze(bigData);

Reducers with high performance requirements can be manually written, while for regular reducers…

--

--

Beck Moulton
Beck Moulton

Written by Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton

No responses yet