Are next-slicezone/hooks actually hooks?

Hi there,

Started working with slice machine today and immediately got warned by eslint about

React Hook "useGetStaticProps" cannot be called at the top level

which I guess is because eslint is warning for every function call prefixed with use. I don't think I'm doing something wrong since I'm just using the code from official docs. Is this expected behaviour? And if so don't you think that naming this packages something different would be less confusing?

Hey @prokomountrichas,

Thanks for posting this error. I'm trying to recreate it, but with no success, and I don't think I've seen it before otherwise.

Could you share your project files so I can take a closer look? You could send a ZIP file or GitHub repo here, or via DM.

Thanks,
Sam

It probably depends on your eslint default configuration @samlittlefair.
I agree that we could get rid of the confusion (not fan of React monopolising the use of use prefix though :wink:)

Yes, sorry, I took it for granted that this plugin is in use which I think is highly recommended to have on anyway.

Fair point @hugo.villain, to be honest I had not thought of this aspect, you're right. However in this case I think it is intentionally made to look like a hook even though it isn't really, which from API design standpoint is a bit problematic.

This issue has been closed due to inactivity. Flag to reopen.