Skip to content

Commit 4127d49

Browse files
Reshapes blog props
1 parent d18071d commit 4127d49

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/routes/blog/components/BlogComponent.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import Post from './PostComponent';
55

66
export default class BlogComponent extends React.Component<IPostsProps, any> {
77
render() {
8-
const { posts, authors } = this.props.posts.entities;
9-
const { isFetching, result: displayPosts } = this.props.posts;
8+
const { posts, authors, isFetching, displayPosts } = this.props;
109

1110
return (
1211
<div>

src/routes/blog/containers/BlogContainer.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ import { IState } from '../../../store';
55
import { IPostsProps } from '../types';
66

77
function stateToProps(state: IState, ownProps: any): IPostsProps {
8-
return { posts: state.posts };
8+
const { posts } = state;
9+
10+
return {
11+
isFetching: posts.isFetching,
12+
posts: posts.entities.posts,
13+
authors: posts.entities.authors,
14+
displayPosts: posts.result,
15+
};
916
}
1017

1118
@connect(stateToProps)

src/routes/blog/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { IPostsState, IState } from '../../store';
1+
import { IPost, IAuthor } from '../../store';
22

33
export interface IPostsProps {
4-
posts: IPostsState;
4+
isFetching: boolean;
5+
posts: { [id: string]: IPost };
6+
authors: { [id: string]: IAuthor };
7+
displayPosts: string[];
58
}

0 commit comments

Comments
 (0)