Skip to content

Commit

Permalink
fix(playground): console scroll to bottom (#9153)
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo authored Jun 23, 2023
1 parent 0caebd9 commit 85871bb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/src/playground/console.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { useEffect, useRef } from "react";

export interface VConsole {
prop: string;
message: string;
}

export function Console({ vConsole }: { vConsole: VConsole[] }) {
const consoleUl = useRef<HTMLUListElement | null>(null);
const scrollToBottom = () => {
consoleUl.current?.scrollTo({ top: consoleUl.current?.scrollHeight });
};
useEffect(() => {
scrollToBottom();
}, [vConsole]);
return (
<div id="play-console">
<span>Console</span>
<ul>
<ul ref={consoleUl}>
{vConsole.map(({ prop, message }, i) => {
return (
<li key={i}>
Expand Down

0 comments on commit 85871bb

Please sign in to comment.