Automattic / Automattic/woocommerce-services

fix: components with side-effects

Open
#2,152 0 comments 0 reactions 0 assignees View on GitHub
[Pri] Low [Type] Enhancement [Type] Technical Debt woocommerce-services
Dominant language
JavaScript
Stars
112
Forks
31
Avg merge
3d 1h
Merged PRs (30d)
14

Description

## Description
It looks like some components' `render` functionality is not a function of props and state, but can have some side-effects on render.

Examples:
- [RatesStep](https://github.com/Automattic/woocommerce-services/blob/develop/client/extensions/woocommerce/woocommerce-services/views/shipping-label/label-purchase-modal/rates-step/index.js)
- Could call `props.updateRate` at each re-render

It is recommended to call functions that can have side effects in a `componentDidMount` or `componentDidUpdate` or `useEffect` method/hook.

Contributor guide

Open the contributing guide

Research direction

Start with client/extensions/woocommerce/woocommerce-services/views/shipping-label/label-purchase-modal/rates-step/index.js and inspect its render path for calls such as props.updateRate. Search the other components for similar render-time side effects, then compare them with the componentDidMount, componentDidUpdate, or useEffect guidance. Done means identified side effects no longer run during render.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.