Skip to content

Best Practices tips for Frontend Coding

veeramarni edited this page Jun 12, 2021 · 9 revisions
  • Synchronous Code only: Don't write any asynchronous code (avoid promises, await) directly in the UI. Use libraries such as React Query to better manage the asynchronous code.

  • No Expansive code: Don't write expensive code with react components that would take full state

    If you ever need to take a full state either from redux or apollo-client and further computed within the component would result in bad performance.

    1. If the state has nested objects which cause the props to more prone to changes causing unwanted Component rendering.

    2. this code won't be reusable.

    So in that case, use selectors and inject them into props so it resolves the above-mentioned issues.