Giter Club home page Giter Club logo

eslint-plugin-goodeffects's People

Contributors

peterkwesiansah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

eslint-plugin-goodeffects's Issues

(new rule):no-derived-state

Sometimes when developing react applications, we find ourselves computing a value based on a state. or a prop .
Now there are two ways to go about this. We either create a derived state, which is a state which gets updated based on the value of another state(primary state). Now with this approach , we find ourselves directly managing dependencies in a useEffect and updating the derived state when ever any of the dependency changes, this is quite hard to maintain and debug as it may not be immediately obvious how and when the derived state updates. Another issue with this approach is that , any update in the derived state will lead to uneccessary re-renders which can be avoided when the value is directly computed during render and not stored directly in a useState . These issues above can be fixed by computing the value directly during render or with a useMemo (if only the computation is expensize).
Enough already let's see some code

BAD
image

GOOD
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.