my plugin creates multiple customFields.
These customFields have their specific use-case however each of them rely on the same data.
singleType: “factory” with customFields: “catchFish”, “inspectFish”, “releaseFish”.
In each of these customFields I rely on all entries in
fishs. These customFields include a dropdown that needs to be populated with ‘fishs’. By using the
useFetchClient-Hook I can fetch data in each customField individually but for me this is not a good solution. (my customFields are used 25+ times on this specific singleType “factory” → this results in noticeable lag)
What is the best way to populate my customFields with the data but prevent them all from fetching the data individually?
I would implement it the same way strapi implements relations.
aka you have a field where you can type in to search and you only get back the first 10 results. and have a loadmore button
factory currently has 25+ OneToOne-Relations. Each of them make an individual request to
This is unchanged strapi behaviour: And is not usable because it seems like the relations are emtpy on initial load and if you don’t wait x seconds.
By using customField I want to improve this behaviour and fetch
/fishs only once and use the fetched data for all customFields.
Is there any other solution / possibility?
Like a contextProvider that can be used by my customFields or something like that?
Do the same thing strapi does for relation fields when you type in them.
Aka if I type 2. the request changes to
/content-manager/relations/api::test2.test2/tests?pageSize=10&_q=2&_filter=$containsi&page=1 what means itdoes a global search on 2
Hey @Boegie19, thanks for your interest in the topic.
I totally understand you however that still would result in 25+ requests on initial load of the singleType in strapi-admin.
I want to fetch the api-endpoint once (like on entering the singleType in strapi-admin) fetch the data (only one time) and store it in redux (meh ) or context and replace my current “original strapi-relations” with customFields that only rely on this data.
That’s why I’m looking for a place where I can storage this data and also get it from there in my customFields.
For example creating a global variable in the same plugin that also contains these different customFields and importing it in the customFields works but would be a (bad) solution. (racing condition, no updates)