# profile-builder/4.0.3/form-builder/blocks/src/lib/existingFieldsSnapshot.js

User Profile Builder – Beautiful User Registration Forms, User Profiles &amp; User Role Editor, version 4.0.3. 22 lines.

- Page: https://pluginprobe.com/plugins/profile-builder/4.0.3/code/form-builder/blocks/src/lib/existingFieldsSnapshot.js
- Raw: https://pluginprobe.com/plugins/profile-builder/4.0.3/raw/form-builder/blocks/src/lib/existingFieldsSnapshot.js
- Modified: 2026-08-17T08:51:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/profile-builder/4.0.3/code/form-builder/blocks/src/lib/existingFieldsSnapshot.js#L10-L20`.

```javascript
/**
 * Live snapshot of global `wppb_manage_fields` for Existing Fields + Conditional Logic.
 * Seeded from the bridge; refreshed by post-save GET and per-edit PUT sync.
 */
import { useSyncExternalStore } from '@wordpress/element';

import { createPubsubStore } from './createPubsubStore';

const store = createPubsubStore(
    ( window.wppbFb && window.wppbFb.existingFields && window.wppbFb.existingFields.fields ) || [],
);

/** Replace the snapshot (post-save refetch, per-edit PUT reconcile, delete). */
export const setExistingFieldsSnapshot = ( next ) => store.set( next );

/** Read imperatively (store-mutating callbacks outside React). */
export const getExistingFieldsSnapshot = () => store.get();

/** Read reactively (React components). */
export const useExistingFieldsSnapshot = () =>
    useSyncExternalStore( store.subscribe, store.get );

```
