Skip to content

Commit

Permalink
Moved recursive function implementation inside useEffect hook as per …
Browse files Browse the repository at this point in the history
…feedback
  • Loading branch information
colin-codegen[bot] authored Aug 18, 2023
1 parent 8813c4b commit c33230d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,23 @@ const createMessage = (text: string, isUserMessage: boolean): Message => {
};
};

// Implement the recursive function that sums an array of integers
const recursiveArraySum = (arr: number[]): number => {
if (arr.length === 0) {
return 0;
}
return arr[0] + recursiveArraySum(arr.slice(1));
};


export default function Chat() {

useEffect(() => {
// Implement the recursive function that sums an array of integers
const recursiveArraySum = (arr: number[]): number => {

Check warning on line 50 in src/components/Chat/Chat.tsx

View workflow job for this annotation

GitHub Actions / Lint with ESLint and Prettier

'recursiveArraySum' is assigned a value but never used
if (arr.length === 0) {
return 0;
}
return arr[0] + recursiveArraySum(arr.slice(1));
};
}, []);

const userId = useAtomValue(chatUserIdAtom);


// ref to track text area and scroll text into view
const ref = useRef<HTMLParagraphElement | null>(null);

Expand Down

0 comments on commit c33230d

Please sign in to comment.