Skip to content

Commit 859ceb4

Browse files
committed
refactor
1 parent 1a9cd36 commit 859ceb4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/App.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,21 +111,23 @@ const Repositories = ({ repositories }) => (
111111
</ul>
112112
);
113113

114-
const Watch = ({ repository }) => (
114+
const Watch = ({
115+
repository: { id, viewerSubscription, watchers },
116+
}) => (
115117
<Mutation
116118
mutation={WATCH_REPOSITORY}
117119
variables={{
118-
id: repository.id,
119-
viewerSubscription: isWatch(repository.viewerSubscription)
120+
id,
121+
viewerSubscription: isWatch(viewerSubscription)
120122
? VIEWER_SUBSCRIPTIONS.UNSUBSCRIBED
121123
: VIEWER_SUBSCRIPTIONS.SUBSCRIBED,
122124
}}
123125
update={updateWatch}
124126
>
125127
{(updateSubscription, { data, loading, error }) => (
126128
<button type="button" onClick={updateSubscription}>
127-
{repository.watchers.totalCount}{' '}
128-
{isWatch(repository.viewerSubscription) ? 'Unwatch' : 'Watch'}
129+
{watchers.totalCount}{' '}
130+
{isWatch(viewerSubscription) ? 'Unwatch' : 'Watch'}
129131
</button>
130132
)}
131133
</Mutation>

0 commit comments

Comments
 (0)