getStaticProps thoughts #359
Replies: 1 comment 2 replies
-
It really depends on the data processing. I've had this challenge in my own app using the At some point, I ran into the "circular dependency issue" with relationships. Because I was resolving those on the server and had to send them to the client (stringified), I had to break the circular issue. At first, I wrote a "limiter" in the relationships resolver, which would limit to resolving 3 levels of circular references. It wasn't such a great idea, as it broke my app randomly depending on how I was manipulating the data. I had to increment it to 4, then 5, and then I noticed how much KB were sent to the browser and it was insane and unpredictable. Eventually I threw that away and rethought the whole processing. At this time, I still perform data sanitization and defaults values on the server, but I resolve the relationships on the client. There, I benefit from the "circular reference feature" and I don't have to bother about knowing whether I manipulate the root objects or nested objects, it simply works. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to take advantage of
getStaticProps
to execute data manipulation logics and return data exactly how it's going to be consume by the client, and even though this might have some performance benefits (server side vs client side) I think it's keeping the code hard to maintain and reason about, and the performance benefits might not really be significant.I'm curious to hear you feedback on this. What do you usually do?
Say you have a big array of objects you fetched on
getStaticProps
and you need to parse it in a specific format to be used in areact-select
kind of component in the client, where would you do this? (getStaticProps or client)Beta Was this translation helpful? Give feedback.
All reactions