Skip to content

Instantly share code, notes, and snippets.

@osdevisnot
Created July 16, 2021 19:09
Show Gist options
  • Save osdevisnot/57929e28f9886241ad0e1423b271d454 to your computer and use it in GitHub Desktop.
Save osdevisnot/57929e28f9886241ad0e1423b271d454 to your computer and use it in GitHub Desktop.
next-component-playground
// src/pages/play/[component].js
import dynamic from "next/dynamic";
import { useRouter } from "next/router";
const Play = () => {
const router = useRouter();
const { component } = router.query;
const DynamicComponent = dynamic(
() => import(`../../components/${component}`),
{
ssr: false,
}
);
return <DynamicComponent />;
};
export default Play;

Create a quick Component Playground in your next project.

// src/components/box.js
const Box = (props) => <div>One & Only Box Component</div>;
export default Box;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment