11import { Tab , TabList , Tabs } from "@chakra-ui/react" ;
22import { css } from "@emotion/react" ;
33import styled from "@emotion/styled" ;
4- import { FC , useState } from "react" ;
4+ import { FC , useMemo , useState } from "react" ;
55import { useRecoilValue } from "recoil" ;
66
77import useTestcaseCommand from "@/commands/useTestcaseCommand" ;
@@ -19,36 +19,39 @@ interface TestcasePanelProps {
1919
2020const TestcasePanel : FC < TestcasePanelProps > = ( { testcaseId } ) => {
2121 const testcaseCommand = useTestcaseCommand ( ) ;
22- const testcase = useRecoilValue ( testcaseFamily ( testcaseId ) ) ;
2322 const runner = useTestcaseRunner ( ) ;
23+ const testcase = useRecoilValue ( testcaseFamily ( testcaseId ) ) ;
2424
2525 const [ selectedTabIndex , setSelectedTabIndex ] = useState ( 0 ) ;
2626
27- const tabs = [
28- {
29- title : "입력" ,
30- content : (
31- < InputEditor
32- value = { testcase . input }
33- onChange = { ( input ) => testcaseCommand . changeValue ( testcaseId , { input } ) }
34- onKeyDown = { ( ) => runner . makeIdle ( testcaseId ) }
35- />
36- ) ,
37- } ,
38- {
39- title : "정답" ,
40- content : (
41- < AnswerEditor
42- value = { testcase . answer }
43- onChange = { ( answer ) => testcaseCommand . changeValue ( testcaseId , { answer } ) }
44- />
45- ) ,
46- } ,
47- {
48- title : "출력결과" ,
49- content : < Result testcaseId = { testcaseId } /> ,
50- } ,
51- ] ;
27+ const tabs = useMemo (
28+ ( ) => [
29+ {
30+ title : "입력" ,
31+ content : (
32+ < InputEditor
33+ value = { testcase . input }
34+ onChange = { ( input ) => testcaseCommand . changeValue ( testcaseId , { input } ) }
35+ onKeyDown = { ( ) => runner . makeIdle ( testcaseId ) }
36+ />
37+ ) ,
38+ } ,
39+ {
40+ title : "정답" ,
41+ content : (
42+ < AnswerEditor
43+ value = { testcase . answer }
44+ onChange = { ( answer ) => testcaseCommand . changeValue ( testcaseId , { answer } ) }
45+ />
46+ ) ,
47+ } ,
48+ {
49+ title : "출력결과" ,
50+ content : < Result testcaseId = { testcaseId } /> ,
51+ } ,
52+ ] ,
53+ [ testcaseId , testcase ] ,
54+ ) ;
5255
5356 return (
5457 < StyledTestcasePanel >
0 commit comments