State Management (MobX) Setup for React Application

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Setting Up State Management (MobX) for React Application

MobX uses reactive programming: observable data, computed values, and reactions (autorun, reaction, when). Components wrapped in observer automatically subscribe to exactly those observables they read during render — no more.

MobX wins where state is complex, object-oriented, or when you need to minimize manual work optimizing re-renders.

What's Involved

Designing store classes, setting up decorators or makeObservable/makeAutoObservable, integrating with React via mobx-react-lite, reactions and side effects, DevTools, persistence, store testing.

Installation

npm install mobx mobx-react-lite

Enable decorators in tsconfig.json when using TypeScript:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "useDefineForClassFields": false
  }
}

Store via makeAutoObservable

Most concise — makeAutoObservable. MobX determines what's observable, computed, and action:

import { makeAutoObservable, runInAction } from 'mobx'

class CartStore {
  items: CartItem[] = []
  loading = false
  error: string | null = null

  constructor() {
    makeAutoObservable(this)
  }

  get total() {
    return this.items.reduce((sum, i) => sum + i.price * i.quantity, 0)
  }

  get count() {
    return this.items.reduce((sum, i) => sum + i.quantity, 0)
  }

  addItem(product: Product) {
    const existing = this.items.find((i) => i.id === product.id)
    if (existing) {
      existing.quantity++
    } else {
      this.items.push({ ...product, quantity: 1 })
    }
  }

  async checkout() {
    this.loading = true
    this.error = null
    try {
      await api.post('/orders', { items: this.items })
      runInAction(() => {
        this.items = []
        this.loading = false
      })
    } catch (err) {
      runInAction(() => {
        this.error = err instanceof Error ? err.message : 'Order error'
        this.loading = false
      })
    }
  }
}

export const cartStore = new CartStore()

Timeline

Basic MobX setup — 1–2 hours. Setting up multiple interdependent stores — 2–3 hours. Complex observable graph — 1 day.