Skip to content

Commit 32f3738

Browse files
committed
introduce put dynamic widget
1 parent 46a5559 commit 32f3738

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pages/index.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,25 @@ import Head from 'next/head';
44
import TextWidget from '@/components/TextWidget';
55
import TimeWidget from '@/components/TimeWidget';
66

7+
const Widgets = {
8+
'text': TextWidget,
9+
'time': TimeWidget,
10+
};
11+
712
const IndexPage = () => {
813
const text = `オレオレOBSウィジュエットの整理`;
14+
15+
const widgets = [
16+
{ name: 'text', props: { text: text } },
17+
{ name: 'time', props: { size: 30 } },
18+
];
19+
920
return (
1021
<div>
11-
<TextWidget text={text} />
12-
<TimeWidget size={30} />
22+
{widgets.map((widget) => {
23+
const Widget = Widgets[widget.name];
24+
return <Widget {...widget.props} />
25+
})}
1326
</div>
1427
);
1528
};

0 commit comments

Comments
 (0)