Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reload not working for collection hooks #5

Open
jamesvclements opened this issue Sep 28, 2023 · 0 comments
Open

Hot reload not working for collection hooks #5

jamesvclements opened this issue Sep 28, 2023 · 0 comments

Comments

@jamesvclements
Copy link

I'm working on a plugin that adds a new collection with a few fields and hooks. Hot reload is working perfectly when I add new fields to the new collection—they instantly show up on the dashboard. But if I had new collection hooks, the changes aren't captured. I have to stop and restart the server for changes to the collection's hooks to be picked up.

I tried both anonymous inline functions in beforeChange

hooks: {
    beforeChange: [() => { console.log('only shows up after manually restarting server') }]
}

and importing the hook from a separate file like in the docs:

import { CollectionBeforeChangeHook } from "payload/types";
const beforeChangeHook: CollectionBeforeChangeHook = async ({
}) => {
  console.log('still only shows up after manually restarting server');
};
export default beforeChangeHook;

Any thoughts on why hooks might be cached or not captured, or if I might have something wrong in my set-up?
The collection is being added per the example:

config.collections = [
  ...(config.collections || []),
  // Add additional collections here
  Videos
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant