Skip to content

Commit

Permalink
Hook instance functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Excellify committed Jun 20, 2024
1 parent ff9a3a0 commit b80054b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 3.1.1.2100

- Fixed an issue where certain hooks would not work properly

### 3.1.1.2000

- Added option to hide 7TV badges from chat
Expand Down
6 changes: 6 additions & 0 deletions src/common/ReactHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ export function defineComponentHook<C extends ReactExtended.WritableComponent>(
if (options.functionHooks) {
for (const [k, f] of Object.entries(options.functionHooks)) {
defineFunctionHook(proto, k as keyof C, f);
for (const instance of instances) {
defineFunctionHook(instance, k as keyof C, f);
}
}
}

Expand Down Expand Up @@ -413,6 +416,9 @@ export function useComponentHook<C extends ReactExtended.WritableComponent>(
if (hook.cls) {
unsetPropertyHook(hook.cls.prototype, k as keyof C);
}
for (const instance of hook.instances) {
unsetPropertyHook(instance.component, k as keyof C);
}
}
}
unhookComponent(hook);
Expand Down

0 comments on commit b80054b

Please sign in to comment.