Skip to content

Commit 4af543b

Browse files
jonniebigodesGatsbyJS Bot
jonniebigodes
authored and
GatsbyJS Bot
committed
fix(examples): Update mobx example (#17479)
* fix(example): dependencies updated and devtools removed Updated the dependencies for the example. Removed mobx-react-devtools as it's deprecated * added examples and edited the issue text * destructure the component and lint correction
1 parent 3d3e68c commit 4af543b

File tree

3 files changed

+52
-53
lines changed

3 files changed

+52
-53
lines changed

examples/using-mobx/package.json

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,36 @@
33
"version": "1.0.0",
44
"private": true,
55
"description": "Gatsby example site that shows use of mobx",
6+
"author": "jonniebigodes",
67
"scripts": {
78
"build": "gatsby build",
89
"develop": "gatsby develop",
9-
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"src/**/*.js\"",
10-
"lint": "eslint **/*.{js,jsx} --quiet -o linterrors.txt --ignore-path .gitignore",
11-
"test": "echo \"Error: no test specified\" && exit 1",
12-
"deploy": "gh-pages -b gh-pages -d public",
13-
"pre-deploy": "gatsby build --prefix-paths"
10+
"format": "prettier --write \"src/**/*.js\"",
11+
"lint": "eslint **/*.{js,jsx} --quiet -o linterrors.txt --ignore-path .gitignore"
1412
},
15-
"main": "n/a",
13+
1614
"keywords": [
1715
"gatsby",
1816
"mobx"
1917
],
20-
"author": "jonniebigodes <[email protected]>",
2118
"license": "MIT",
2219
"dependencies": {
23-
"gatsby": "^2.0.21",
24-
"mobx": "^5.1.0",
25-
"mobx-react": "^5.2.8",
26-
"mobx-react-devtools": "^6.0.3",
27-
"react": "^16.5.0",
28-
"react-dom": "^16.5.0"
20+
"gatsby": "^2.15.9",
21+
"mobx": "^5.13.0",
22+
"mobx-react": "^6.1.3",
23+
"prop-types": "^15.7.2",
24+
"react": "^16.9.0",
25+
"react-dom": "^16.9.0"
2926
},
3027
"devDependencies": {
31-
"babel-eslint": "^9.0.0",
32-
"eslint": "^5.5.0",
33-
"eslint-config-airbnb": "^17.1.0",
34-
"eslint-config-prettier": "^3.0.1",
35-
"eslint-plugin-import": "^2.14.0",
36-
"eslint-plugin-jsx-a11y": "^6.1.1",
37-
"eslint-plugin-prettier": "^2.6.2",
38-
"eslint-plugin-react": "^7.11.1",
39-
"gh-pages": "^1.2.0",
40-
"prettier": "^1.14.2"
28+
"babel-eslint": "^10.0.3",
29+
"eslint": "^6.3.0",
30+
"eslint-config-airbnb": "^18.0.1",
31+
"eslint-config-prettier": "^6.2.0",
32+
"eslint-plugin-import": "^2.18.2",
33+
"eslint-plugin-jsx-a11y": "^6.2.3",
34+
"eslint-plugin-prettier": "^3.1.0",
35+
"eslint-plugin-react": "^7.14.3",
36+
"prettier": "^1.18.2"
4137
}
4238
}

examples/using-mobx/readme.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ Gatsby example site that shows use of mobx.
99
To use mobx in a Gatsby site you'll need to hook in to two of Gatsby's extension points.
1010

1111
Once in wrapRootElement which runs during Gatsby's server rendering process, and once in wrapRootElement which is part of Gatsby's browser APIs.
12-
Check out [./gatsby-ssr.js](./gatsby-ssr.js) and [./gatsby-browser.js](./gatsby-browser.js) to see how this is implemented in this example
1312

14-
## More Information on MobX
13+
Check out [./gatsby-ssr.js](./gatsby-ssr.js) and [./gatsby-browser.js](./gatsby-browser.js) to see how this is implemented in this example.
1514

16-
[Docs](https://mobx.js.org/)
15+
## More information
1716

18-
[Examples](https://github.com/mobxjs/mobx-examples)
17+
[mobx-react-devtools](https://github.com/mobxjs/mobx-react-devtools) package is now deprecated and was removed. As it could generate the error [Cannot read property 'on' of undefined](https://github.com/mobxjs/mobx-react-devtools/issues/117).
18+
19+
To allow access to some form of development tools, install the plugin for your browser of choice like mentioned [here](https://github.com/mobxjs/mobx-devtools).
20+
21+
[Official Documentation](https://mobx.js.org/)
22+
23+
[Mobx Examples](https://github.com/mobxjs/mobx-examples)
Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
import React, { Component } from "react"
1+
import React from "react"
2+
import PropTypes from "prop-types"
23
import { Link } from "gatsby"
34
import Counter from "./Counter"
45

5-
import DevTools from "mobx-react-devtools"
6+
const DefaultLayout = ({ children }) => (
7+
<div>
8+
<Link to="/">
9+
<h3>MobX example</h3>
10+
</Link>
11+
<Counter />
612

7-
class DefaultLayout extends Component {
8-
render() {
9-
return (
10-
<div>
11-
<Link to="/">
12-
<h3>MobX example</h3>
13-
</Link>
14-
<DevTools />
15-
<Counter />
16-
<ul>
17-
<li>
18-
<Link to="/a/">a</Link>
19-
</li>
20-
<li>
21-
<Link to="/b/">b</Link>
22-
</li>
23-
<li>
24-
<Link to="/c/">c</Link>
25-
</li>
26-
</ul>
27-
{this.props.children}
28-
</div>
29-
)
30-
}
13+
<ul>
14+
<li>
15+
<Link to="/a/">a</Link>
16+
</li>
17+
<li>
18+
<Link to="/b/">b</Link>
19+
</li>
20+
<li>
21+
<Link to="/c/">c</Link>
22+
</li>
23+
</ul>
24+
{children}
25+
</div>
26+
)
27+
DefaultLayout.propTypes = {
28+
children: PropTypes.object.isRequired,
3129
}
3230
export default DefaultLayout

0 commit comments

Comments
 (0)