From d6d6f9928875d808b6ab5d922cbc5b61e849640b Mon Sep 17 00:00:00 2001 From: David Zhao Date: Mon, 27 Mar 2023 12:06:12 -0700 Subject: [PATCH] Add tab=custom to jump straight to custom connection (#43) With the goal of fully replacing example.livekit --- pages/index.tsx | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index df713a5..793c0f1 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,11 +1,16 @@ import type { NextPage } from 'next'; import { useRouter } from 'next/router'; -import React, { ReactElement, ReactNode } from 'react'; -import { useState } from 'react'; +import React, { ReactElement, useCallback, useEffect, useState } from 'react'; import styles from '../styles/Home.module.css'; -function Tabs(props: { children: ReactElement[] }) { - const [activeIndex, setActiveIndex] = useState(0); +interface TabsProps { + children: ReactElement[]; + selectedIndex?: number; + onTabSelected?: (index: number) => void; +} + +function Tabs(props: TabsProps) { + const activeIndex = props.selectedIndex ?? 0; if (!props.children) { return <>; } @@ -14,7 +19,9 @@ function Tabs(props: { children: ReactElement[] }) { return (