You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Component.dataHooks always is an array of the data hooks from other components and the createDataHook function.
similarly getStaticProps, unless extra static props are desired, is also the same every time you write it: calling getDataHooksProps.
couldn't both of these be generated by the babel plugin? from my little experience from using babel, this shouldn't be too tricky to make, and it would reduce a lot of extra code that is copied from page to page, and eliminates the chance of missing a step.
the only issue here would be how to know weather to use getStaticProps or getServerSideProps, since you can't tell that from the hook usage themselves.
i'd like to try to implement this, maybe as an optional thing you need to enable. what are your thoughts?
The text was updated successfully, but these errors were encountered:
I've thought of this too! It's a super cool idea and I'm definitely happy to explore some options around it. This lib already ships a babel plugin for code elimination so it could be pretty natural to add more babel magic.
To be upfront though, if we were to ship, it would definitely be under an experimental flag. I feel like there are some challenges to work out and it's hard to know if we got it right on the first try.
If you want to give it a go, I'd love to see the code but I can't promise you I'll merge it (but who knows, maybe this just works).
Feel free to change up any internal APIs to make it work (e.g. maybe a new createServerDataHook function can fix the problem you describe). We can start from an ideal API state and then work in backwards compatibility later.
modifying the api was my concern. the ambiguous "is it static props or server props" and also changing behavior in a very breaking way. i will give it a try, and it if doesnt get merged due to that, i can just keep it as a fork or something.
part of the motivation was from a work in progress thing very similar to this project, but implemented by modifying next itself. to be honest this is 100x cleaner than my approach, and my end goal is basically this project but with the extra automation i described.
i'll update this issue with any significant progress.
Update (for anyone interested): lots of progress on this one. @davecaruso's changes are currently present in the alpha branch and this is something I've committed to polishing for 1.0.0
Component.dataHooks
always is an array of the data hooks from other components and thecreateDataHook
function.similarly
getStaticProps
, unless extra static props are desired, is also the same every time you write it: callinggetDataHooksProps
.couldn't both of these be generated by the babel plugin? from my little experience from using babel, this shouldn't be too tricky to make, and it would reduce a lot of extra code that is copied from page to page, and eliminates the chance of missing a step.
the only issue here would be how to know weather to use getStaticProps or getServerSideProps, since you can't tell that from the hook usage themselves.
i'd like to try to implement this, maybe as an optional thing you need to enable. what are your thoughts?
The text was updated successfully, but these errors were encountered: