Dataset #276
-
I'm still trying to get my head around Also every time you need any prop you need to search in the entire dataset to get and I don't think that's ideal, unless I'm missing something here. Also why you're doing this: const customer: Customer = find(dataset, { __typename: 'Customer' }) as Customer; rather than just access the customer directly with Another worry is about using it with Sorry so many questions, I'm in the middle a merge and there are a lot of new changes coming that I need to understand better. 😅 Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Basically, the
It's easier to manage this way, in the case of the demo where all pages are injected with a dataset. The data contained within the dataset might be different from page to page, but all expect a One of the benefit is the dataset is automatically serialized, so no matter what data you store there it won't break in case of circular reference. Also, it centralize "all fetched data" into a central place, where it's easier to look for (instead of creating maybe 20 different props as pageProps).
I chose to do it that way because of how Airtable API works. I hadn't noticed until now but with the graphCMS preset it can be I'm going to change for
It's not exactly true regarding "dynamic" data. It's totally fine to use React context to store dynamic data, as long as they are immutable. And in the case of this demo, they are (nothing is going to mutate anything in the dataset). Because the data doesn't change dynamically, it's fine using Context. Agreed that if you mutate your dataset it's going to be very bad because any change will trigger a full page render because all components would update. But in the present case, it can't happen. |
Beta Was this translation helpful? Give feedback.
Basically, the
dataset
contains all dynamic values coming from the database.It's easier to manage this way, in the case of the demo where all pages are injected with a dataset. The data contained within the dataset might be different from page to page, but all expect a
dataset
property, containing at least the customer and the theme to apply to the UI.One of the benefit is the dataset is automatically serialized, so no matter what data you store there it won't break in case of circular refe…