export const genericApp = `import "./styles.css";
import Child from "./Child";
const testData = {
name: "xfy",
age: 18
};
export default function App() {
return (
Hello CodeSandbox
Start editing to see some magic happen!
);
}`;
export const genericChild = `import { useState } from "react";
type Props> = {
name: keyof T;
data: T;
};
const Child = >({ name, data }: Props) => {
const [showName, setShowName] = useState();
const valid = () => {
console.log(data[name]);
setShowName(data[name]);
};
return (
<>
{name}
{JSON.stringify(showName)}
>
);
};
export default Child;`;
export const hookApp = `import { useForm } from 'react-hook-form';
type Pet = 'Cat' | 'Dog';
type FormData = {
firstName: string;
lastName: string;
favorite: Pet;
};
export default function App() {
const {
register,
handleSubmit,
formState: { errors },
} = useForm();
const onSubmit = handleSubmit((data) => console.log(data));
return (
);
}`;