Skip to content

Commit

Permalink
bug 🪲: (created in this branch)
Browse files Browse the repository at this point in the history
index.js:1 Warning: Cannot update a component (`SpeechTextComponent`) while rendering a different component (`_c`).

*NOTE `_c` is the SpeechboxArrow component

fix 🛠️:
only set the `arrowWidth` state after component has been created using the `useEffect` hook
  • Loading branch information
arnard76 committed Jul 30, 2023
1 parent 45ed971 commit e56f948
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/SpeechboxArrow.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import Triangle from "components/Triangle";

const SpeechTextboxArrow = React.memo(({ borderWidth, setArrowWidth }) => {
Expand Down Expand Up @@ -43,7 +43,9 @@ const SpeechTextboxArrow = React.memo(({ borderWidth, setArrowWidth }) => {

const borderTriangleWidth = calculateBorderTriangleWidth();
const borderTriangleHeight = calculateBorderTriangleHeight();
setArrowWidth(borderTriangleWidth);
useEffect(() => {
setArrowWidth(borderTriangleWidth);
}, []);

return (
<div
Expand Down

0 comments on commit e56f948

Please sign in to comment.