Skip to content

react-hooks-strict-return gets triggered, even in the return of built in hooks like useMemo #370

@hagnerd

Description

@hagnerd

Overview

The react-hooks-strict-return rule incorrectly gets triggered in built in hook calls (useMemo, useCallback, useState, potentially others).

Example

function useExampleHook(input) {
  const options = useMemo(() => [
    `${input}1`,
    `${input}2`,
    `${input}3`,
    // eslint error gets reported here
  ], [input]);

  
  // ... even if this doesn't return `options` the rule gets triggered.
}

Consuming repo

What repo were you working in when this issue occurred?

The Shopify Web repo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions