Menu

1 / 2

React Native offline-first: fast set logging UI

DEV Community·Sathish·6 months ago
#Nc1dMafF
Reading 0:00
15s threshold

I stopped blocking the UI on SQLite writes.

I log sets in-memory first, then flush.

I use a tiny write queue + one transaction.

I ship a “pending” state that never lies.

Context

My fitness app has one job during a workout.

Log a set in under 5 seconds.

I started with “just write to SQLite on button tap”.

Brutal.

Every tap waited on IO. Then React re-rendered. Then the list jumped.

Also offline-first means I can’t punt to the server.

SQLite is the source of truth.

But the UI can’t feel like a database client.

So I split it.

UI writes to memory instantly.

SQLite catches up in the background.

If SQLite fails, I show it.

No silent drops.

1) I treat SQLite like a sink, not my UI state

My first version did this:

Tap “+”. Await insert. Then query.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.