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

Remove unnecessary condition #846

Merged
merged 1 commit into from
Apr 1, 2021

Conversation

sweetliquid
Copy link
Contributor

@sweetliquid sweetliquid commented Dec 11, 2020

For extraReducers, when it is a function it will not be undefined, when it is undefined we defined a default value for it. Therefore, the judment of undefined is redundant :)

const [
extraReducers = {},
actionMatchers = [],
defaultCaseReducer = undefined
] =
typeof options.extraReducers === 'undefined'
? []
: typeof options.extraReducers === 'function'
? executeReducerBuilderCallback(options.extraReducers)
: [options.extraReducers]

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 473d32f:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration

typeof options.extraReducers === 'undefined'
? []
: typeof options.extraReducers === 'function'
typeof options.extraReducers === 'function'
Copy link
Contributor

Choose a reason for hiding this comment

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

If options.extraReducers === undefined, then the result would be [undefined], right?

Copy link
Member

Choose a reason for hiding this comment

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

It's a little "wrap-your-head-around" with this.

for options.extraReducers === undefined, this would result in

 const [ 
   extraReducers = {}, 
   actionMatchers = [], 
   defaultCaseReducer = undefined 
 ] = [undefined]

which would then take on the default value of extraReducers = {} at desctructuring.

So yeah, I believe the PR is correct, but I'd like a second opinion here @markerikson or @msutkowski

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's go with it.

@markerikson markerikson merged commit 37d22c4 into reduxjs:next Apr 1, 2021
@markerikson
Copy link
Collaborator

Eh, this shoulda gone to master. manually merging back locally.

@sweetliquid sweetliquid deleted the remove-unnecessary-condition branch February 7, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants