Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Rect Redux 8 & Redux Toolkit #64

Merged
merged 9 commits into from
Feb 14, 2023

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Nov 28, 2022

Bumps react-redux from 7.2.8 to 8.0.5.

Release notes

Sourced from react-redux's releases.

v8.0.5

This release fixes a few minor TS issues.

What's Changed

Full Changelog: reduxjs/react-redux@v8.0.4...v8.0.5

v8.0.4

This patch release fixes some minor TS types issues, and updates the rarely-used areStatesEqual option for connect to now pass through ownProps for additional use in determining which pieces of state to compare if desired.

Note: 8.0.3 was accidentally published without one of these fixes. Use 8.0.4 instead.

Changelog

TS Fixes

We've fixed an import of React that caused issues with the allowSyntheticDefaultImports TS compiler flag in user projects.

connect already accepted a custom context instance as props.context, and had runtime checks in case users were passing through a real value with app data as props.context instead. However, the TS types did not handle that case, and this would fail to compile. If your own component expects props.context with actual data, connect's types now use that type instead.

The ConnectedProps<T> type had a mismatch with React's built-in React.ComponentProps<Component> type, and that should now work correctly.

Other Changes

The areStatesEqual option to connect now receives ownProps as well, in case you need to make a more specific comparison with certain sections of state.

The new signature is:

{
  areStatesEqual?: (
    nextState: State,
    prevState: State,
    nextOwnProps: TOwnProps,
    prevOwnProps: TOwnProps
  ) => boolean
}

What's Changed

... (truncated)

Commits
  • 8d03182 Release 8.0.5
  • 32e40e4 Merge pull request #1928 from marconi1992/fix/1927
  • ff7d96b fix: type when passing nullish mapDispathToProps
  • 5082af7 Merge pull request #1965 from reduxjs/draft/amazing-rosalind
  • bafe55e Add typetests
  • fc3954a Update test matrix to Node 16 and TS 4.9
  • 401250e also update TypedUseSelectorHook
  • 3b06061 wrap type in
  • ad40b97 Merge pull request #1960 from OliverJAsh/patch-1
  • 8cf538c Merge pull request #1966 from ethen001/chores/custom-equality-fn-docs
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

@mgrabovsky
Copy link
Collaborator

mgrabovsky commented Dec 1, 2022

This is going to need a couple of changes in our code. I've started with crafting a patch, but I'll leave this blocked for now.

@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch from 295eb53 to add1ce9 Compare December 5, 2022 13:14
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch from add1ce9 to 36689a1 Compare January 2, 2023 12:05
@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch 2 times, most recently from 07aac2d to 69e655d Compare January 30, 2023 11:57
@mgrabovsky mgrabovsky force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch from 26ed720 to e2f35a7 Compare January 31, 2023 13:02
Copy link
Collaborator

@mgrabovsky mgrabovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the affected code and converted our reducers to use Redux Toolkit. However, the gating tests page reducer seems to have got broken, so I'm blocking this for now.

@Andrei-Stepanov
Copy link
Contributor

In general I feel strange about this PR.
Was it necessary to rename reducer to slice in this PR?
Was this term slice introduced in this major release update?
Also see note about removing actions.

I think, that in this PR should be code that resolves update redux from 7 to 8

@Andrei-Stepanov
Copy link
Contributor

Created a jira-ticket for this: https://issues.redhat.com/browse/OSCI-4547

@mgrabovsky mgrabovsky force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch from e2f35a7 to e7b23cb Compare February 1, 2023 14:53
@mgrabovsky mgrabovsky changed the title Bump react-redux from 7.2.8 to 8.0.5 Upgrade to Rect Redux 8 & Redux Toolkit Feb 10, 2023
@mgrabovsky mgrabovsky force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch 4 times, most recently from 7129abf to 23799c7 Compare February 10, 2023 14:26
@mgrabovsky
Copy link
Collaborator

@Andrei-Stepanov I think this is ready for review. I've split the changes so that there's one commit per slice/reducers, so it will be easier to review going through the commits one by one.

@mgrabovsky mgrabovsky self-requested a review February 10, 2023 14:27
return state;
}
};
state.queryString = newQueryString;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this actually work? Without update ?

import update from 'immutability-helper';

Copy link
Collaborator

@mgrabovsky mgrabovsky Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Redux Toolkit uses the Immer library to handle in-place state updates. So we can now write code like in the old times, but it's still sort of immutable in the background.

@Andrei-Stepanov
Copy link
Contributor

@mgrabovsky looks good.
But I have one question about import update from 'immutability-helper';
You removed. I am not sure that it is correct.
Could you please explain this place a bit more.
Purpose of this utility is to updata object at specified path, using a specific method, creating a NEW object with old values and new values at specified path.
How new code works at this place?

Bumps [react-redux](https://github.com/reduxjs/react-redux) from 7.2.8 to 8.0.5.
- [Release notes](https://github.com/reduxjs/react-redux/releases)
- [Changelog](https://github.com/reduxjs/react-redux/blob/master/CHANGELOG.md)
- [Commits](reduxjs/react-redux@v7.2.8...v8.0.5)

---
updated-dependencies:
- dependency-name: react-redux
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@mgrabovsky
Copy link
Collaborator

@Andrei-Stepanov See my response above. Redux Toolkit uses Immer under the hood, which watches for mutations on the state and automatically creates an immutable copy with the changes applied in the background.

This means that we don't have to call update() in Redux reducers any more and we can instead modify the state "directly", as Immer will do the updates for us automatically.

The `redux-thunk` library is no longer needed when using Redux Toolkit.
See the [documentation][1]. Moreover, the Redux DevTools are set up
automatically as well so there's no need for dedicated code.

[1]: https://redux-toolkit.js.org/usage/usage-guide#using-middleware-to-enable-async-logic
Follow the new nomeclature of Redux Toolkit where both reducers and
actions stem from slices.
@mgrabovsky mgrabovsky force-pushed the dependabot/npm_and_yarn/react-redux-8.0.5 branch from 23799c7 to 93807f8 Compare February 13, 2023 14:46
@mgrabovsky
Copy link
Collaborator

I have now added the clarifying comment as requested above.

@Andrei-Stepanov
Copy link
Contributor

I have now added the clarifying comment as requested above.

Thank you! Please merge.

@mgrabovsky mgrabovsky merged commit 965f180 into main Feb 14, 2023
@mgrabovsky mgrabovsky deleted the dependabot/npm_and_yarn/react-redux-8.0.5 branch February 14, 2023 11:58
mgrabovsky added a commit that referenced this pull request Jun 8, 2023
Use the specialized `useAppDispatch()` and `useAppSelector()` hooks
everywhere.

Follow-up to  #64
mgrabovsky added a commit that referenced this pull request Jun 8, 2023
Use the specialized `useAppDispatch()` and `useAppSelector()` hooks
everywhere.

Follow-up to  #64
mgrabovsky added a commit that referenced this pull request Jun 8, 2023
Use the specialized `useAppDispatch()` and `useAppSelector()` hooks
everywhere.

Follow-up to  #64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants