# db

Source: https://developers.inkdrop.app/states/db

An [app state](https://developers.inkdrop.app/guides/flux-architecture) of the database synchronization.
It can be used to watch the data sync status and errors.
You can obtain the `db` state and integrate it with React components.

---

## Data Structure

- **isSyncing** (boolean | undefined)

  `true` if the database is currently syncing.
  `undefined` if it has not ever been synced yet since the app launched.
- **lastSyncTime** (number | null | undefined)

  The last datetime when the database finished syncing.
  `undefined` if it has not ever been synced yet since the app launched.
- **lastSyncError** (Error | null | undefined)

  The last error ocurred while syncing.

Get the `db` state manually:

```js
const { db } = env.store.getState()
```

Connect the state with your React component:

```js
import { useSelector } from 'react-redux'
const selector = ({ db }) => db
const MyComponent = props => {
  const db = useSelector(selector)
  // render
}
```

[db]: https://developers.inkdrop.app/data-access/db
