foreignId) and you want to render a combined view without duplicating data in Replyke.
How It Works
Pass aninfuseData function to useEntityList. For each entity that has a foreignId, the hook calls your function with that foreignId and merges the result into the entity under an infusion key.
Results are cached by foreignId — each external record is only fetched once per list instance.
Usage Example
infuseData Signature
- Called once per unique
foreignIdin the current list - Return
nullif the record is not found — the entity will still be included with an emptyinfusion: {}object - Errors thrown inside
infuseDataare caught and logged; the entity is included with empty infusion data
infusedEntities vs entities
useEntityList returns two arrays:
| Property | Type | Description |
|---|---|---|
entities | Entity[] | Raw entities from Replyke |
infusedEntities | (Entity & { infusion: Record<string, any> })[] | Entities merged with your external data |
infusedEntities when rendering — it always has the same length as entities and contains an infusion object on each item (empty if no foreignId or if infuseData returned null).
If
infuseData is not passed to useEntityList, infusedEntities will be an empty array. Always use entities when you do not need infusion.
