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

Pushing for help with Redux selectors #880

Merged
merged 6 commits into from Dec 19, 2017

Conversation

Projects
None yet
3 participants
@daovist
Copy link
Contributor

daovist commented Dec 18, 2017

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.

@liamcardenas

This comment has been minimized.

Copy link
Contributor

liamcardenas commented Dec 18, 2017

I'm looking into this

@@ -121,6 +124,11 @@ class VideoPlayer extends React.PureComponent {
}
}

pauseVideo() {

This comment has been minimized.

@liamcardenas

liamcardenas Dec 18, 2017

Contributor

what if you change this to componentWillReceiveProps instead of pauseVideo?

This comment has been minimized.

@liamcardenas

liamcardenas Dec 18, 2017

Contributor

then of course you would need to filter out the prop changes that don't lead to a pause, but does that make sense?

This comment has been minimized.

@daovist

daovist Dec 18, 2017

Author Contributor

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.

This comment has been minimized.

@kauffj

kauffj Dec 18, 2017

Member

@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) => ({

This comment has been minimized.

@liamcardenas

liamcardenas Dec 18, 2017

Contributor

this should go in videos/index.js

@@ -56,8 +57,11 @@ class Video extends React.PureComponent {
changeVolume,
volume,
uri,
// videoPause,

This comment has been minimized.

@liamcardenas

liamcardenas Dec 18, 2017

Contributor

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;

This comment has been minimized.

@liamcardenas

liamcardenas Dec 18, 2017

Contributor

this should be

const _selectState = state => state.video || {};

@liamcardenas
Copy link
Contributor

liamcardenas left a comment

Looks great! just this one question/change

componentWillReceiveProps(nextProps) {
if (nextProps.videoPause) {
this.refs.media.children[0].pause();
this.props.setVideoPause(false);

This comment has been minimized.

@liamcardenas

liamcardenas Dec 19, 2017

Contributor

is this (this.props.setVideoPause(false);) necessary? can we trigger this, instead, when they push "play" in app?

@liamcardenas

This comment has been minimized.

Copy link
Contributor

liamcardenas commented Dec 19, 2017

Making a follow up issue to this since this is work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.