我正在尝试通过将视频ID传递给选择器来从redux-saga调用组合选择器
import { createSelector } from 'reselect';
const selectVideoStore = state => state.video;
export const selectVideos = createSelector(
[selectVideoStore],
video => video.videos
);
export const selectVideosForPreview = ytid =>
createSelector(
[selectVideos],
videos => (videos ? videos[ytid] : null)
);
const selectedVideo = yield select(selectVideosForPreview, ytid);
console.log({ selectedVideo });
这将返回selectedVideo
中的函数
您的selectVideosForPreview
不是选择器,而是选择器工厂。因此,您需要先创建选择器,然后再将其传递到yield select()
:
const selectedVideo = yield select(selectVideosForPreview(ytid));