useAction Hook is obligating to install redux-related packages when using blackout-react
dnamorim opened this issue · 1 comments
dnamorim commented
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
- 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 thehelpers/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
- 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
jhairabreu commented
Fixed in #500