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

react-redux 7 bug return exact props type component #3788

Open
ease-space opened this issue Mar 22, 2020 · 9 comments
Open

react-redux 7 bug return exact props type component #3788

ease-space opened this issue Mar 22, 2020 · 9 comments

Comments

@ease-space
Copy link

ease-space commented Mar 22, 2020

problem ConnectedComponent return exact Config props
Снимок экрана от 2020-03-22 17-46-54
Снимок экрана от 2020-03-22 17-41-40
Снимок экрана от 2020-03-22 17-47-40
I fixed this problem
Снимок экрана от 2020-03-22 17-42-04
Снимок экрана от 2020-03-22 17-41-15

@ease-space
Copy link
Author

ease-space commented Mar 22, 2020

But OwnProps should be non exact type
Finish fix which also corrects the previous error
Снимок экрана от 2020-03-22 18-32-06

@ease-space
Copy link
Author

ease-space commented Mar 22, 2020

Access danied pull request
Снимок экрана от 2020-03-22 18-52-30

@jedwards1211
Copy link
Contributor

@maystrenkoYurii you need to fork this repository and push to your own fork, then you can make a pull request

@jedwards1211
Copy link
Contributor

To do this using the hub CLI:

cd ~/flow-typed
hub fork
hub push --set-upstream maystrenkoYurii react-redux-fix-issue-3788
hub pull-request

@ease-space
Copy link
Author

@jedwards1211
sorry but ci build fail and I don't understand why

@jedwards1211
Copy link
Contributor

jedwards1211 commented Mar 23, 2020

Yeah, the react-redux types are so complicated I don't know if I can figure it out either. You can run the same tests that CI is running in your local copy by doing this:

cd ~/flow-typed/cli
yarn
node dist/cli.js run-tests react-redux

How come you're using $Exact in

return connect<Props, $Exact<OwnProps>, ...

I assume you get some other errors if you don't use $Exact there?

The new useSelector hook is generally easier to use, especially with Flow. If you use React >=16.8.0 you could do this:

import * as React from 'react'
import { useSelector } from 'react-redux'

export const ResetScrollOnLocationChange = () => {
  const locationUrl = useSelector(getRouterLocationUrlWithReselect)
  const mounted = React.useRef(false)
  React.useEffect(() => {
    if (mounted.current) window.scrollTo(0, 0)
    mounted.current = true
  }, [locationUrl])
  return null
}

And then render <ResetScrollOnLocationChange /> inside any route you want to reset scroll for.

(You can also use connect to build a component like this, instead of wrapping your route components.)

@ease-space
Copy link
Author

@jedwards1211 i am run test local without changes node v12 but its fail
add only \n end fail
Снимок экрана от 2020-03-25 21-22-07

@AndrewSouthpaw
Copy link
Contributor

Looks like the react-redux_v7 tests are indeed broken in master.

@ease-space
Copy link
Author

ease-space commented Mar 26, 2020

@jedwards1211
before change
Снимок экрана от 2020-03-26 21-06-39
Снимок экрана от 2020-03-26 21-09-01
Снимок экрана от 2020-03-26 21-10-14

after chenge(before 2 screen) good work in my project
Снимок экрана от 2020-03-26 21-19-52
and insurance that the component will return non exact ownProps
Снимок экрана от 2020-03-26 21-44-08

I think the resulting component should return Component with non Exact props

but tests failes in master branch even without changes

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

No branches or pull requests

3 participants