-
The team I'm on has been seeing uncaught exceptions bubbling up from this function and after reviewing the implementation I can't quite grasp how it's expected to work. Utility in question: https://github.com/microsoft/fluentui/blob/master/packages/utilities/src/initializeComponentRef.ts It seems to be "extending" a given react component by wrapping some react component lifecycle methods. The part I'm not understanding in particular though is how the lifecycle functions in initializeComponentRef.ts expect as their first argument the "this" context. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ah, my confusion came from not being aware of the handling of "this" as a fake argument parameter which is solely used for type hinting. Described here https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function. The "this" argument is removed from the transpiled output which means the "prevProps" argument is the actual first argument, as expected. |
Beta Was this translation helpful? Give feedback.
Ah, my confusion came from not being aware of the handling of "this" as a fake argument parameter which is solely used for type hinting. Described here https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function.
The "this" argument is removed from the transpiled output which means the "prevProps" argument is the actual first argument, as expected.