Skip to content

Commit

Permalink
feat(Redux): Drop reselect in favour for Redux toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
danactive committed Jul 2, 2020
1 parent b138d6b commit a83791c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
10 changes: 1 addition & 9 deletions ui/internals/generators/container/index.js.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { FormattedMessage } from 'react-intl';
{{/if}}
{{#if wantActionsAndReducer}}
import { useSelector, useDispatch } from 'react-redux';
import { createStructuredSelector } from 'reselect';
{{/if}}

{{#if wantActionsAndReducer}}
Expand All @@ -36,12 +35,6 @@ import saga from './saga';
import messages from './messages';
{{/if}}

{{#if wantActionsAndReducer}}
const stateSelector = createStructuredSelector({
{{camelCase name}}: makeSelect{{properCase name}}(),
});
{{/if}}

function {{ properCase name }}() {
{{#if wantActionsAndReducer}}
useInjectReducer({ key: '{{ camelCase name }}', reducer });
Expand All @@ -51,9 +44,8 @@ function {{ properCase name }}() {
{{/if}}
{{#if wantActionsAndReducer}}

/* eslint-disable no-unused-vars */
const { {{camelCase name}} } = useSelector(stateSelector);
const dispatch = useDispatch();
const { {{camelCase name}} } = useSelector(selector);
/* eslint-enable no-unused-vars */
{{/if}}

Expand Down
6 changes: 3 additions & 3 deletions ui/internals/generators/container/selectors.js.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createSelector } from 'reselect';
import { createSelector } from '@reduxjs/toolkit';

import { initialState } from './reducer';

/**
Expand All @@ -15,8 +16,7 @@ const select{{ properCase name }}Domain = state => state.{{ camelCase name }} ||
* Default selector used by {{ properCase name }}
*/

const makeSelect{{ properCase name }} = () =>
createSelector(select{{ properCase name }}Domain, substate => substate);
const makeSelect{{ properCase name }} = createSelector(select{{ properCase name }}Domain, substate => substate);

export default makeSelect{{ properCase name }};
export { select{{ properCase name }}Domain };
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createSelector } from 'reselect';
import { createSelector } from '@reduxjs/toolkit';

import { initialState } from './reducer';

/**
Expand Down

0 comments on commit a83791c

Please sign in to comment.