Farfetch/blackout

useAction Hook is obligating to install redux-related packages when using blackout-react

dnamorim opened this issue · 1 comments

Expected behaviour

When using the helpers from blackout-react, no redux-related packages should be required to be installed, if we use no features this package which don't require redux explicity:

import { headers, getTimeInMinutes } from '@farfetch/blackout-react`;

...

Actual behaviour

When we import helpers, like this:

import { headers, getTimeInMinutes } from '@farfetch/blackout-react`;

...

as the @farfetch/blackout-react exports useAction on the helpers/index.ts, it requires the installation of redux and react-redux.

Steps to reproduce

  1. Open a project without redux and react-redux installed
  2. Try to make the following import
import { headers, getTimeInMinutes } from '@farfetch/blackout-react`;
  1. Run the project

Context/environment

This happens on projects that have installed @farfetch/blackout-react but doesn't have redux and react-redux and need to use some react helpers.

Possible fix

  1. Don't export helpers/useAction.ts directly on the helpers/index.ts, and require users to use a explicitly path, like:
import { useAction } from @farfetch/blackout-react/helpers/withRedux
// or
import useAction from @farfetch/blackout-react/helpers/useAction
  1. Remove useAction, as this function is known for having performance issues and is not recommended (see https://react-redux.js.org/api/hooks#recipe-useactions) and pass the decision to use that for the tenant

Fixed in #500