Skip to content

Commit 92886f6

Browse files
author
devmagazinepodcast
committed
Add why-did-you-render
1 parent 0d305fe commit 92886f6

File tree

5 files changed

+306
-5
lines changed

5 files changed

+306
-5
lines changed

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: ['eslint:recommended', 'plugin:react/recommended'],
3+
plugins: ['react-hooks'],
4+
rules: {
5+
'react-hooks/rules-of-hooks': 'error',
6+
'react-hooks/exhaustive-deps': 'warn',
7+
'react/prop-types': 0,
8+
},
9+
parserOptions: {
10+
ecmaVersion: 9,
11+
sourceType: 'module',
12+
ecmaFeatures: {
13+
jsx: true,
14+
experimentalObjectRestSpread: true,
15+
experimentalArrayRestSpread: true,
16+
},
17+
},
18+
env: {
19+
browser: true,
20+
node: true,
21+
},
22+
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
2-
"name": "react-template-empty",
2+
"name": "react-optimization-hooks",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
66
"@testing-library/jest-dom": "^4.2.4",
77
"@testing-library/react": "^9.3.2",
88
"@testing-library/user-event": "^7.1.2",
9+
"@welldone-software/why-did-you-render": "^4.2.5",
910
"bootstrap": "^4.5.0",
11+
"eslint": "^7.4.0",
12+
"eslint-plugin-react": "^7.20.3",
1013
"react": "^16.13.1",
1114
"react-bootstrap": "^1.0.1",
1215
"react-dom": "^16.13.1",

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import './wdyr'
2+
13
import React from 'react'
24
import ReactDOM from 'react-dom'
35
import 'bootstrap/dist/css/bootstrap.min.css'

src/wdyr.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react'
2+
3+
if (process.env.NODE_ENV === 'development') {
4+
const whyDidYouRender = require('@welldone-software/why-did-you-render')
5+
whyDidYouRender(React, {
6+
trackAllPureComponents: true,
7+
})
8+
}

0 commit comments

Comments
 (0)