Skip to content
Discussion options

You must be logged in to vote

Using structuralSharing and select is the right way to do this. The trick to prevent your ColumnList from re-rendering is to also use the select there as the list doesn't care if any part of the column object change. It only cares if the array of column IDs change:

export const ColumnList = React.forwardRef<React.ElementRef<"div">, ColumnListProps>(
  function ColumnListComponent({ className, ...props }, ref) {
    const { data: columns } = useUserQuery({ userId }, { select: u => u?.columns.map(c => c.id) })

    if (!columns) {
      return <div>Loading...</div>
    }

    return (
      <div
        {...props}
        className={cn("flex flex-wrap gap-8 ", className)}
        ref={ref}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vitormarkis
Comment options

Answer selected by vitormarkis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants