Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WHAT
🤖 Generated by Copilot at 28ee390
This pull request enhances the performance of the UI components and the editor page by using React memoization techniques. It also adds a preview feature for the editor and fixes some variable naming issues. The main files affected are
Button.tsx
,EditorToolbar.tsx
,useDate.ts
, andeditor.tsx
.🤖 Generated by Copilot at 28ee390
WHY
Fixed the issue of some editor elements being re-rendered redundantly.
Before:
https://user-images.githubusercontent.com/18638914/232337151-5beb824e-43f6-49a0-ab1e-15e276412066.mp4
After:
https://user-images.githubusercontent.com/18638914/232337155-5cfe16bf-03c9-4361-8755-ec3622e9aaa1.mp4
HOW
🤖 Generated by Copilot at 28ee390
Button
andEditorToolbar
components withmemo
function and passareEqual
function to compare props and prevent unnecessary re-rendering (link, link, link, link)renderToolbar
function withuseCallback
function and pass dependency array to memoize value and avoid creating new functions on every render (link)useDate
hook withuseMemo
function and pass dependency array to memoize value and avoid recomputing on every render unless language changes (link, link)ExtraProperties
variable toextraProperties
and wrap it withuseMemo
function and pass dependency array to memoize value and avoid recreating JSX elements on every render unless one of the dependencies changes (link, link)onPreviewButtonClick
function and wrap it withuseCallback
function and pass dependency array to memoize value and avoid creating new function on every render (link)onPreviewButtonClick
function aspreviewPage
prop ofEditor
component andonClick
prop ofButton
component instead of creating new functions on every render (link, link)