diff --git a/examples/web/react/app.tsx b/examples/web/react/app.tsx index 0307e7f9744a8de310365a00c6f758a5b9b1c622..3ee47fffd2c15feb51f8e67d7bc6384feea86d60 100644 --- a/examples/web/react/app.tsx +++ b/examples/web/react/app.tsx @@ -15,34 +15,6 @@ export const App = () => { const [count, setCount] = useState(0); const getText = () => `Hello World ${count}`; const onClick = () => setCount(count + 1); - const pairs = () => [ - <Pair key="tobias" name={"Tobias"} value={`Count ${count}`} />, - <Pair key="matias" name={"Matias"} value={"3"} />, - <Pair - key="button-tobias" - name={"Button Increment"} - valueNode={ - <ButtonIncrement - value={200} - delta={100} - min={0} - suffix={"Hz"} - /> - } - />, - <Pair - key="button-cpu" - name={"Button Switch"} - valueNode={ - <ButtonSwitch - options={["NEO", "CLASSIC"]} - size={"large"} - style={["simple"]} - onChange={(v) => alert(v)} - /> - } - /> - ]; return ( <> <Button text={getText()} onClick={onClick} /> @@ -52,7 +24,34 @@ export const App = () => { imageAlt="tobias" onClick={onClick} /> - <Info pairs={pairs()} /> + <Info> + <Pair key="tobias" name={"Tobias"} value={`Count ${count}`} /> + <Pair key="matias" name={"Matias"} value={"3"} /> + <Pair + key="button-tobias" + name={"Button Increment"} + valueNode={ + <ButtonIncrement + value={200} + delta={100} + min={0} + suffix={"Hz"} + /> + } + /> + <Pair + key="button-cpu" + name={"Button Switch"} + valueNode={ + <ButtonSwitch + options={["NEO", "CLASSIC"]} + size={"large"} + style={["simple"]} + onChange={(v) => alert(v)} + /> + } + /> + </Info> </> ); }; diff --git a/examples/web/react/components/info/info.tsx b/examples/web/react/components/info/info.tsx index e91952c84bac9dd7804e36ac321df61e6ab8ea1e..ce6130a4e0656948c79168392a4c45d60aab9254 100644 --- a/examples/web/react/components/info/info.tsx +++ b/examples/web/react/components/info/info.tsx @@ -3,7 +3,7 @@ import React, { FC, ReactNode } from "react"; import "./info.css"; type InfoProps = { - pairs?: ReactNode[]; + children?: ReactNode; style?: string[]; }; @@ -18,9 +18,9 @@ type InfoProps = { * to build the info pairs. * @returns The info component with the associated pairs. */ -export const Info: FC<InfoProps> = ({ pairs = [], style = [] }) => { +export const Info: FC<InfoProps> = ({ children = [], style = [] }) => { const classes = () => ["info", ...style].join(" "); - return <dl className={classes()}>{pairs}</dl>; + return <dl className={classes()}>{children}</dl>; }; export default Info;