Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional components #89

Open
dnorrstrand opened this issue Jul 11, 2022 · 1 comment
Open

Functional components #89

dnorrstrand opened this issue Jul 11, 2022 · 1 comment

Comments

@dnorrstrand
Copy link

Hi
Does this library work with functional components? Thanks

@lqduy
Copy link

lqduy commented Sep 7, 2024

This is not a Function component library. However, you can do the following (Here I use the MUI library):

import Box from "@mui/material/Box"
import { Draggable as SmoothDraggable } from "react-smooth-dnd"
import { type ReactNode } from "react"
import { type SxProps } from "@mui/material"

interface TypeProps {
  children: ReactNode
  sx?: SxProps
}

const DndDraggable: React.FC<TypeProps> = ({ children, sx }) => {
  return <SmoothDraggable render={() => <Box sx={sx}>{children}</Box>} />
}

export default DndDraggable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants