feat: implementing translations api#434
feat: implementing translations api#434gloaysa wants to merge 16 commits intoyoopta-editor:masterfrom
Conversation
|
@gloaysa is attempting to deploy a commit to the dargo's projects Team on Vercel. A member of the Team first needs to authorize it. |
| if (render) { | ||
| return ( | ||
| // [TODO] - take care about SSR | ||
| const menuContent = render ? render({ ...renderProps, actions: blockTypes }) : <DefaultActionMenuRender {...renderProps} actions={blockTypes} />; |
There was a problem hiding this comment.
The original code conditionally skips parts of the component tree based on render, which changes the structure React expects, violating the Rules of Hooks; the fix ensures consistent structure by dynamically selecting content via a variable.
I hope is ok, had to tackle this issue on this PR since it was introducing a bug (I'm using the new useTranslate hook in the conditionally rendered children DefaultActionMenuRender).
| }); | ||
|
|
||
| const blockTypes: ActionMenuToolItem[] = mapActionMenuItems(editor, items || Object.keys(editor.blocks)); | ||
| const blockTypes = useMemo(() => mapActionMenuItems(editor, items || Object.keys(editor.blocks)), [editor, items]); |
There was a problem hiding this comment.
This change is not directly related to my feature, I'm just following the boy-scout rule.
I've noticed that this is recalculated on every render. If editor or items doesn’t change, this causes unnecessary re-renders.
|
|
||
| useEffect(() => { | ||
| setActions(blockTypes); | ||
| setSelectedAction(blockTypes[0]); |
There was a problem hiding this comment.
This change is not directly related to my feature, I'm just following the boy-scout rule.
If loading actions dynamically, the list wasn't being updated. This change syncs the actions if the blockTypes change.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
#273
Type of change
Please tick the relevant option.
Checklist:
Screenshots:
Screen.Recording.2025-01-04.at.17.10.45.mov