why-did-you-render
eslint-plugin-react
Our great sponsors
why-did-you-render | eslint-plugin-react | |
---|---|---|
47 | 67 | |
10,763 | 8,800 | |
1.2% | 0.4% | |
7.0 | 8.6 | |
15 days ago | 6 days ago | |
JavaScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
why-did-you-render
- Too many rerenders in react?
- Lag issues with RN
-
After a year developing with react, I think I've been doing all wrong
For debugging why a specific component re-renders, there is also why did you render
-
Why and How We Retired Elm at Culture Amp
It's a combination of many things, but imo one of the worst is all the footguns regarding state and the rerenders they cause
https://emnudge.dev/blog/react-hostage
It's so easy, that we monkey patch react to debug it https://github.com/welldone-software/why-did-you-render
Plus the vdom... Isn't great, the bundle size puts react at an inherit disadvantage, and the community has a knack for over reliance on bloated packages
-
7 Proven Practices to Boost Development Speed and Project Quality
When we implemented the MVP of the fintech app, we had a quite complicated form. At that time, I was still young and inexperienced. And eventually, we realized that our project was slowing down. We had to spend additional hours figuring out the reason. We had many unnecessary re-renders because we ignored basic rules related to props in React. I wanted to do everything possible to avoid such situations in the future. So, I added to the project linters like this and an additional starting configuration to package.json to run why-did-you-render. In short, this plugin issues a warning if something is re-rendered unnecessarily and suggests how to avoid it. Also, we included running Lighthouse in headless mode. Some people say that premature optimizations are bad, but for me, it's a principle: do it right from the start.
- Free code review
- How do you test number of re-renders?
-
Tools to track re-renders
Couple of questions popped up after discovering this tool called `why-did-you-render`. My understanding is that it helps you keep track of why certain components render.
-
Are there any tools available to help see if useEffect() has a memory leak?
Not exactly what you are looking for (stop runaway effects is it) but this helps diagnose re-renders which can be related: https://github.com/welldone-software/why-did-you-render
eslint-plugin-react
-
Interesting Bugs Caught by ESLint's no-constant-binary-expression
> [1] https://github.com/jsx-eslint/eslint-plugin-react/blob/maste...
From what I remember, being able to pass children as a prop is considered a side-effect of an implementation detail, that breaks the expected abstraction. There really isn't any reason to use it, and I think there's a chance it may even confuse the virtual dom diffing?
Also this would prevent you from accidentally doing both at once:
Is it me?}>
This is pretty compelling. Why isn't it in the "recommended" preset of lints?
In general, I find it frustrating that the eslint recommended presets don't document why they are recommended. I disable several of the rules in all my projects because they seem to be arbitrary stylistic choices (e.g. [0], [1], [2]).
[0] https://typescript-eslint.io/rules/no-empty-function/
[1] https://github.com/jsx-eslint/eslint-plugin-react/blob/maste...
[2] Specifically checkLoops of https://eslint.org/docs/latest/rules/no-constant-condition
-
Speeding up the JavaScript ecosystem – Polyfills gone rogue
For what it's worth; `eslint-plugin-react` has been around for a long time and seems to support running in very old versions of Node.JS (back to v4[1] apparently! tho I can't find anything documenting that for sure.)
I was surprised to learn that Object.values is only supported in Node >v7, Object.fronEntries was added in v12, etc. So for this project maybe the polyfills are needed.
[1] https://github.com/jsx-eslint/eslint-plugin-react/pull/1038
I try to focus on the issues rather than individuals, but the root of the problems in the listed eslint plugin libraries points to ljharb.
If you do some simple digging into these libraries, you will find that these types of commits are quite common within them.
https://github.com/jsx-eslint/eslint-plugin-react/commit/e1d...
https://github.com/jsx-eslint/jsx-ast-utils/commit/bad51d062...
https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/commit/...
He would rather see the download count of these polyfill libraries https://github.com/ljharb/ljharb#projects-i-maintain increase, compared to assessing the health of the JavaScript ecosystem.
-
The Best ESLint Rules for React Projects
An obvious pick for React projects, but eslint-plugin-react along with their plugin:react/recommended rule set is a must. This will give you some sensible rules such as requiring a key to be specified in JSX arrays. eslint-config-airbnb is another good (if a bit loose) base rule set on top of eslint-plugin-react to start from.
-
Create React UI Lib 1.1: Ladle and ESLint
You can also add ESLint now (props to @femincan for the suggestion). It comes with recommended settings for these plugins: typescript, prettier, react, react-hooks, jsx-a11y.
-
Ask HN: What are you predictions for 2023?
Thanks for weighing in, that's good to know. After wondering if this could be auto-refactored, I came across https://github.com/jsx-eslint/eslint-plugin-react/blob/maste..., will definitely have to give that (with `--fix`) a try in the new year and see if I can get the team on board! – desire for typescript being a compelling factor.
Personally I do like the non-destructured `props.abc` throughout component code, really helps clarify at a glance where something is coming from, whether it's locally or externally defined, etc. Code style is an endless exercise in compromises/opinions though, even _with_ tools like eslint and prettier.
-
Recommended React Hooks Convention
eslint-plugin-react react/hook-use-state
-
Implementing serverless chat in React
The conclusion is to pass callback functions to setState hooks when one needs the current state or props to calculate the next state. React is then able to reliably queue up these "pipes" / transformations to apply to the current state, without relying on what the current state actually is. This is almost so important that there should be an ESLint plugin for this (and there is one).
-
Setting up ESLint & Prettier in ViteJS
eslint-plugin-react: React specific linting rules for ESLint.
What are some alternatives?
craco - Create React App Configuration Override, an easy and comprehensible configuration layer for Create React App.
use-what-changed - A React hook and an easy to use babel-pugin to debug various React official hooks
nextjs-rewrite-test
react-render-tracker - React render tracker – a tool to discover performance issues related to unintentional re-renders and unmounts
react-devtools - An extension that allows inspection of React component hierarchy in the Chrome and Firefox Developer Tools.
stylelint-config-prettier - Turns off all rules that are unnecessary or might conflict with prettier.
razzle - ✨ Create server-rendered universal JavaScript applications with no configuration
RunJS - RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
berry - 📦🐈 Active development trunk for Yarn ⚒
MineRender - Quick, Easy, Interactive 3D/2D Renders of Minecraft
prop-types - Runtime type checking for React props and similar objects
javascript - JavaScript Style Guide