Skip to content

Commit

Permalink
fix: add memoization to hooks example to improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Jun 7, 2019
1 parent a1584d9 commit 497afda
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/examples-hooks/src/04-sortable/stress-test/Card.tsx
@@ -1,4 +1,4 @@
import React, { useMemo, useRef } from 'react'
import React, { memo, useMemo, useRef } from 'react'
import { __EXPERIMENTAL_DND_HOOKS_THAT_MAY_CHANGE_AND_BREAK_MY_BUILD__ } from 'react-dnd'
import ItemTypes from './ItemTypes'
const {
Expand All @@ -20,7 +20,7 @@ export interface CardProps {
moveCard: (draggedId: string, id: string) => void
}

const Card: React.FC<CardProps> = ({ id, text, moveCard }) => {
const Card: React.FC<CardProps> = memo(({ id, text, moveCard }) => {
const ref = useRef(null)
const [{ isDragging }, connectDrag] = useDrag({
item: { id, type: ItemTypes.CARD },
Expand Down Expand Up @@ -50,6 +50,6 @@ const Card: React.FC<CardProps> = ({ id, text, moveCard }) => {
{text}
</div>
)
}
})

export default Card

0 comments on commit 497afda

Please sign in to comment.