Hello, pardon me if I’ve missed a solution for the following issue somewhere else, haven’t found anything related.
I want to show multiple Sections inside a popup (without SSR). In order to achieve that I’m adding multiple BuilderComponent
s.
<BuilderComponent
model="registration-block"
options={{
userAttributes: {
locale,
},
query: {
'data.position': 'top',
'data.isActive': true,
},
}}
/>
/* .................. */
<BuilderComponent
model="registration-block"
options={{
userAttributes: {
locale,
},
query: {
'data.position': 'bottom',
'data.isActive': true,
},
}}
/>
The important thing is that the model is the same for the two components. If written as above code makes only one request to Builder API and uses the result in both components.
Seems like BuilderComponent caches results just by the model name. A workaround that I found is to add key
to options
like that:
<BuilderComponent
model="registration-block"
options={{
key: 'bottomThing',
userAttributes: {
locale,
},
query: {
'data.position': 'bottom',
'data.isActive': true,
},
}}
/>
It works but it produces requests to API that I would consider broken because it uses non-existent endpoint (bottomThing
) and overwrites the model with query parameter:
"https://cdn.builder.io/api/v1/query/key-12345/bottomThing?omit=meta.componentsUsed&apiKey=key-12345&userAttributes.locale=ja&options.bottomThing.query=%7B%22data.position%22%3A%22bottom%22%2C%22data.isActive%22%3Atrue%7D&options.bottomThing.model=%22registration-block%22"
Another option is to get content via builder API (doesn’t matter serverside or from the client) and feed it directly to content
property of BuidlerCompenent
. But it’s less descriptive and requires extra code.
Am I missing something? Is this a by-design behavior for BuilderComponent?
Maybe I should use a different approach altogether.