Skip to content

Hook Reevaluation due to task recreation #3

@adam-rocska

Description

@adam-rocska

As a user of the library it's normal to do this:

      useTaskQueue({
        name: 'test',
        codec: json.number,
        task: v => [v * 2, v * 3, v * 4],
      })

The problem is, that doing so in a react component or a wrapper hook, the task function's reference will always "change" therefore React will assume, that our memorized value should be re-evaluated.

  const task = useMemo(() => descriptor.task, [descriptor.task]);

Gotta somehow fix react's function change detection.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions