Skip to content

Commit daacd79

Browse files
danger9224solkimicreb
authored andcommitted
test(pokedex): updated formatting
1 parent a23e4a6 commit daacd79

File tree

7 files changed

+46
-58
lines changed

7 files changed

+46
-58
lines changed

.DS_Store

-6 KB
Binary file not shown.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ Instead of returning an object, you should directly mutate the received stores.
614614

615615
#### Advanced
616616

617+
- [Pokédex](https://risingstack.github.io/react-easy-state/examples/pokedex/build) ([source](/examples/pokedex/)) ([codesandbox](https://codesandbox.io/s/github/RisingStack/react-easy-state/tree/master/examples/pokedex)): a Pokédex app build with Apollo GraphQL, async actions and a global state.
617618
- [TodoMVC](https://risingstack.github.io/react-easy-state/examples/todo-mvc/build) ([source](/examples/todo-mvc/)) ([codesandbox](https://codesandbox.io/s/github/RisingStack/react-easy-state/tree/master/examples/todo-mvc)): a classic TodoMVC implementation with a lot of computed data and implicit reactivity.
618619
- [Contacts Table](https://risingstack.github.io/react-easy-state/examples/contacts/build) ([source](/examples/contacts/)) ([codesandbox](https://codesandbox.io/s/github/RisingStack/react-easy-state/tree/master/examples/contacts)): a data grid implementation with a mix of global and local state.
619620
- [Beer Finder](https://risingstack.github.io/react-easy-state/examples/beer-finder/build) ([source](/examples/beer-finder/)) ([codesandbox](https://codesandbox.io/s/github/RisingStack/react-easy-state/tree/master/examples/beer-finder)) ([tutorial](https://medium.com/@solkimicreb/design-patterns-with-react-easy-state-830b927acc7c)): an app with async actions and a mix of local and global state, which finds matching beers for your meal.

examples/.DS_Store

-6 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SKIP_PREFLIGHT_CHECK=true

examples/pokedex/.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,8 @@
88
# testing
99
/coverage
1010

11-
# production
12-
/build
13-
1411
# misc
1512
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
2013

2114
npm-debug.log*
2215
yarn-debug.log*

examples/pokedex/src/api.js

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,38 @@
1-
import { gql } from "apollo-boost";
2-
import { ApolloClient } from "apollo-client";
3-
import { createHttpLink } from "apollo-link-http";
4-
import { InMemoryCache } from "apollo-cache-inmemory";
1+
import { gql } from 'apollo-boost';
2+
import { ApolloClient } from 'apollo-client';
3+
import { createHttpLink } from 'apollo-link-http';
4+
import { InMemoryCache } from 'apollo-cache-inmemory';
55

66
const httpLink = createHttpLink({
7-
uri: "https://graphql-pokemon.now.sh/"
7+
uri: 'https://graphql-pokemon.now.sh/',
88
});
99

1010
const client = new ApolloClient({
1111
link: httpLink,
12-
cache: new InMemoryCache()
12+
cache: new InMemoryCache(),
1313
});
1414

1515
export const fetchList = async () => {
16-
let data;
17-
18-
await client
19-
.query({
20-
query: gql`
21-
{
22-
pokemons(first: 10000) {
23-
id
24-
name
25-
image
26-
classification
27-
types
28-
}
16+
const result = await client.query({
17+
query: gql`
18+
{
19+
pokemons(first: 10000) {
20+
id
21+
name
22+
image
23+
classification
24+
types
2925
}
30-
`
31-
})
32-
.then(result => {
33-
data = result.data.pokemons;
34-
});
26+
}
27+
`,
28+
});
3529

36-
return data;
30+
return result.data.pokemons;
3731
};
3832

39-
export const fetchPokemon = async (id) => {
40-
let data;
41-
42-
await client
43-
.query({
44-
query: gql`
33+
export const fetchPokemon = async id => {
34+
const result = await client.query({
35+
query: gql`
4536
{
4637
pokemon(id: "${id}") {
4738
id
@@ -85,11 +76,8 @@ export const fetchPokemon = async (id) => {
8576
}
8677
}
8778
}
88-
`
89-
})
90-
.then(result => {
91-
data = result.data.pokemon;
92-
});
79+
`,
80+
});
9381

94-
return data;
82+
return result.data.pokemon;
9583
};

examples/pokedex/src/components/Modal.js

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from "react";
2-
import { view } from "react-easy-state";
3-
import pokedex from "../store";
4-
import Attack from "./Attack";
5-
import Type from "./Type";
6-
import Card from "./Card";
1+
import React from 'react';
2+
import { view } from 'react-easy-state';
3+
import pokedex from '../store';
4+
import Attack from './Attack';
5+
import Type from './Type';
6+
import Card from './Card';
77

88
export default view(() => {
99
if (!pokedex.selectedPokemon) return null;
@@ -22,12 +22,18 @@ export default view(() => {
2222
fleeRate,
2323
evolutions,
2424
evolutionRequirements,
25-
attacks
25+
attacks,
2626
} = pokedex.selectedPokemon;
2727

2828
return (
29-
<div className="modal-container" onClick={() => pokedex.hideModal()}>
30-
<div className="modal-content" onClick={e => e.stopPropagation()}>
29+
<div
30+
className="modal-container"
31+
onClick={() => pokedex.hideModal()}
32+
>
33+
<div
34+
className="modal-content"
35+
onClick={e => e.stopPropagation()}
36+
>
3137
{pokedex.selectedPokemon && (
3238
<>
3339
{pokedex.isSelectedPokemonLoading ? (
@@ -89,17 +95,16 @@ export default view(() => {
8995
<>
9096
<h3>Evolution</h3>
9197
<div className="evolution-container">
92-
{evolutions.map(item => {
93-
console.log(item);
94-
return <Card key={item.id} {...item} mini />;
95-
})}
98+
{evolutions.map(item => (
99+
<Card key={item.id} {...item} mini />
100+
))}
96101
</div>
97102
</>
98103
)}
99104
{evolutionRequirements && (
100105
<p>
101106
<b>Evolution requirements: </b>
102-
{evolutionRequirements.amount}{" "}
107+
{evolutionRequirements.amount}{' '}
103108
{evolutionRequirements.name}
104109
</p>
105110
)}

0 commit comments

Comments
 (0)