-
Notifications
You must be signed in to change notification settings - Fork 0
/
List.js
executable file
·61 lines (53 loc) · 1.71 KB
/
List.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React from 'react'
import ArticlePromotion from '../components/ArticlePromotion'
import { graphql } from 'react-apollo'
import gql from 'graphql-tag'
import styles from '../css/List'
const List = ({ category, packages, loading }) => (
loading ? <span>Loading</span> : (<div className={styles.list}>
<div className={styles.title}>Category: {category}</div>
<div className={styles.content}>
<ul>{packages.map(pkg => <li key={pkg}>{pkg}</li>)}</ul>{category === 'redux' ? <ArticlePromotion
title='Wanna master data-fetching? Read:'
text='Redux-First Router data-fetching: solving the 80% use case for async Middleware 🚀'
url='https://medium.com/faceyspacey/redux-first-router-data-fetching-solving-the-80-use-case-for-async-middleware-14529606c262'
/> : <ArticlePromotion
title='New to Rudy?? Learn how it started and its motivation:'
text='Pre Release: Redux-First Router — A Step Beyond Redux-Little-Router 🚀'
url='https://medium.com/faceyspacey/pre-release-redux-first-router-a-step-beyond-redux-little-router-cd2716576aea'
/>}
</div>
</div>)
)
const GET_LIST = gql`
query getList {
state {
category
packages
}
}
`
const WrappedList = graphql(GET_LIST, {
props: ({ loading, error, data: { state: { category, packages } } }) => {
if (loading) {
return { loading }
}
if (error) {
return { error }
}
return {
loading: false,
category,
packages
}
}
})(List);
export default WrappedList
/*
const mapStateToProps = state => ({
category: state.category,
packages: state.packages
})
export default List
export default connect(mapStateToProps)(List)
*/