Skip to content

Commit

Permalink
Add cmt regarding shallow copy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonfelixrico committed Apr 24, 2024
1 parent a66420a commit 591b099
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ export function useRectangleInputServiceImpl(): RectangleInputService {
id: nanoid(),
}

/*
* It's important that we create pass a shallow copy of the data instead of passing it directly.
* Passing a shallow copy will end up causing writes to the draft ref to be blocked by React since
* that same ref is being used in the state now.
*/
dispatch(PadActions.setDraftRectangle({ ...data }))
sendMessage(PadSocketCode.SHAPE_DRAFT_START, data)
draft.current = data
Expand Down

0 comments on commit 591b099

Please sign in to comment.