Closed alamgir8 closed 9 months ago
The error doesn't seem to come from this lib but from the array-move
one.
Actually I just noticed that the lib was also directly importing from array-move... https://github.com/ValentinH/react-easy-sort/blob/main/src/index.tsx#L1
Could you share an example showing the issue?
@ValentinH, Thanks for your quick reply. Yes, I know it's coming from other packages. So, I think it will be better to attach those two functions for array move into your package instead of using the external package so that your package will be independent and will not cause any issues, As those two simple functions.
I made two custom functions instead of using their package array-move and now it's working fine.
Thanks
Ok so it means that the issue wasn't due to our internal usage of array-move.
What version were you using? Maybe it's shipping ESM and you need to let Next.js know about it.
I'm using the latest version of both your and the array-move package(Now the array-move package is removed), Node version 18.18.2
Ok I understand: the latest version (4.0.0) is indeed shipping ESM. See https://github.com/sindresorhus/array-move/releases/tag/v4.0.0
If you really wanted to use it in Next.js, you would have to pass it to the transpilePackages
option.
On my side, I might eventually include the function directly in the lib to limit the dependencies, even though v3.0 works fine.
I'm trying to use it with next.js version 13.5.5. but it shows an error when try to drag, Here is my setup
`import { arrayMoveImmutable } from "array-move"; import SortableList, { SortableItem } from "react-easy-sort";
const MenuCard = ({ menuRef, menuToggle, categoryList, handleSorting, handleScrollMenu, }) => { const { showingTranslateValue } = useUtilsFunction(); const [categoryList, setCategoryList] = useState([]);
const handleSorting = (oldIndex, newIndex) => { setCategoryList((array) => arrayMoveImmutable(array, oldIndex, newIndex)); };
return ( <div ref={menuRef} className="flex w-full overflow-y-scroll scrollbar-hide items-center gap-4 whitespace-nowrap"
export default MenuCard;`
The error is this : _TypeError: (0 , array_move__WEBPACK_IMPORTED_MODULE_0__.default) is not a function
_![Screenshot 2023-11-15 at 1 29 43 PM](https://github.com/ValentinH/react-easy-sort/assets/52715776/cdd950dd-6d50-47be-876c-2681ef0ac368)