в файле PostDetailPage / index. js:
import PostDetail from 'components/PostDetail';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
import React from 'react';
import PropTypes from 'prop-types';
import { useInjectReducer } from 'utils/injectReducer';
import { useInjectSaga } from 'utils/injectSaga';
import { makeSelectUser } from 'containers/App/selectors';
import reducer from './reducer';
import saga from './saga';
import fetchPost from './actions';
const key = 'detail';
const PostDetailPage = ({ match, getPost }) => {
useInjectReducer({ key, reducer });
useInjectSaga({ key, saga });
const postId = match.params.id;
getPost(postId);
return <div>detail post</div>;
};
const mapStateToProps = createStructuredSelector({
currentUser: makeSelectUser(),
});
const mapDispatchToProps = dispatch => ({
getPost: postId => dispatch(fetchPost(postId)),
});
PostDetailPage.propTypes = {
match: PropTypes.object,
getPost: PropTypes.func,
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(PostDetailPage);
в действиях у меня есть "fetchPost":
import { FETCH_POST } from './constants';
export const fetchPost = postId => ({ type: FETCH_POST, postId });
когда я запускаю localhost, он показывает ошибку "Uncaught (в обещание) TypeError: Object (...) не является функцией "Пожалуйста, помогите мне проверить код!