Blackout is the codename for the Farfetch Platform Solutions (FPS) projects. Useful to build e-commerce applications using the FPS APIs and integrating business logic.
MIT License
42
stars
15
forks
source link
useAction Hook is obligating to install redux-related packages when using blackout-react #401
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
Open a project without redux and react-redux installed
Try to make the following import
import { headers, getTimeInMinutes } from '@farfetch/blackout-react`;
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
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
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:Actual behaviour
When we import helpers, like this:
as the
@farfetch/blackout-react
exportsuseAction
on thehelpers/index.ts
, it requires the installation ofredux
andreact-redux
.Steps to reproduce
Context/environment
This happens on projects that have installed
@farfetch/blackout-react
but doesn't haveredux
andreact-redux
and need to use some react helpers.Possible fix
Don't export
helpers/useAction.ts
directly on thehelpers/index.ts
, and require users to use a explicitly path, like: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