Got eslint Warn with sensors
#814
Answered
by
clauderic
MatteoGauthier
asked this question in
Q&A
-
Hey I got this warning, do you know how to fix this ?
const sensors = [useSensor(PointerSensor)];
// ...
const renderShapesList = useMemo(
() => (
<DndContext id={'dnd-context'} sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
<SortableContext items={shapes.map((shape) => shape.id)} strategy={rectSortingStrategy}>
{/*
items
*/}
</SortableContext>
</DndContext>
),
[handleDelete, handleDragEnd, handleToggleVisibility, sensors, shapes],
); Does someone can help me ? |
Beta Was this translation helpful? Give feedback.
Answered by
clauderic
Jun 27, 2022
Replies: 1 comment 1 reply
-
You can import import {useSensors} from '@dnd-kit/core';
const sensors = useSensors(
useSensor(PointerSensor)];
); Having said that, I'm not sure why you need to memoize the rendered JSX for your shapes list, seems completely un-necessary. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
clauderic
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can import
useSensors
from@dnd-kit/core
which usesuseMemo
internally to memoize the sensors:Having said that, I'm not sure why you need to memoize the rendered JSX for your shapes list, seems completely un-necessary.