Back to articles
What I Stopped Doing in React Projects (and Why My Code Got Better)

What I Stopped Doing in React Projects (and Why My Code Got Better)

via Dev.toMuhammed Sodiq

I spent months building a production React platform that manages campaigns, customer conversations, and permissions across multiple organizations. Somewhere around the third month, I realized the code wasn't getting worse because I was doing too little — it was getting worse because I was doing too much. Writing maintainable React code isn't about following best practices. It's about knowing which practices to stop following. Here are five things I eliminated, and the measurable improvements that followed. 1. I Stopped Using Redux for Server State Before: 200 Lines of Boilerplate Every time I needed to fetch data from an API, I wrote code like this: // 3 action types, 1 action creator, 1 reducer, 2 selectors... const FETCH_CAMPAIGNS_REQUEST = " FETCH_CAMPAIGNS_REQUEST " ; const FETCH_CAMPAIGNS_SUCCESS = " FETCH_CAMPAIGNS_SUCCESS " ; const FETCH_CAMPAIGNS_FAILURE = " FETCH_CAMPAIGNS_FAILURE " ; export const fetchCampaigns = ( page ) => async ( dispatch ) => { dispatch ({ type : FETCH_CA

Continue reading on Dev.to

Opens in a new tab

Read Full Article
2 views

Related Articles