-
Notifications
You must be signed in to change notification settings - Fork 414
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
Pushing for help with Redux selectors #880
Conversation
I'm looking into this |
@@ -121,6 +124,11 @@ class VideoPlayer extends React.PureComponent { | |||
} | |||
} | |||
|
|||
pauseVideo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if you change this to componentWillReceiveProps
instead of pauseVideo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then of course you would need to filter out the prop changes that don't lead to a pause, but does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that and the method(?) was never called.
I think the issue is that the selector isn't working, or that the reducer isn't actually changing the state. My focus is on line 63 of components/video.view.jsx where it console logs the value of videoPause. It's always false, even after I've clicked open, which should update valuePause to true through the reducer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daovist try using the console to help debug what unexpected behavior is happening here. The console will show all action dispatches as well as all state changes (expand the console messages that are printed on action dispatches). This should tell you whether it's an issue with actions or the reducer. If both the action is fired and the Redux state looks correct, you can add a console statement to see if the selector is firing when you think it ought to.
</div> | ||
); | ||
} | ||
} | ||
|
||
export default VideoPlayer; | ||
const select = (state, props) => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go in videos/index.js
@@ -56,8 +57,11 @@ class Video extends React.PureComponent { | |||
changeVolume, | |||
volume, | |||
uri, | |||
// videoPause, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you want this in here, and then you want to pass it into VideoPlayer
import * as settings from "constants/settings"; | ||
import { createSelector } from "reselect"; | ||
|
||
const _selectState = state => state.videoPause || false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be
const _selectState = state => state.video || {};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! just this one question/change
componentWillReceiveProps(nextProps) { | ||
if (nextProps.videoPause) { | ||
this.refs.media.children[0].pause(); | ||
this.props.setVideoPause(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this (this.props.setVideoPause(false);
) necessary? can we trigger this, instead, when they push "play" in app?
Making a follow up issue to this since this is work. |
I watched a Redux video and read some of the docs. I've created my action (please ignore the do and confirm actions, I will delete those, sorry) and reducer and they seem to be working but my selector is not. I could use help on this. I think once I manage to get the videoPause value from the store into the VideoPlayer component I will be able to wrap this up.