In PO UI v2, passing functions to component properties without explicit binding is deprecated. You must now use .bind(this) to ensure the function executes within the correct component context. This applies to functions passed within arrays or via property binding.
Affected Components:
PageChangePassword, ButtonGroup, Menu, MenuPanel, Navbar, PageList, PageDefault, Popup, Stepper, Table, and Toolbar.
Examples:
1. Functions inside arrays (e.g., PoPageAction):
// Before
actions: Array<PoPageAction> = [
{ label: 'Adicionar', action: this.add }
]
// After
actions: Array<PoPageAction> = [
{ label: 'Adicionar', action: this.add.bind(this) }
]
2. Functions via property binding:
<!-- Before -->
<po-step p-label="Personal" [p-can-active-next-step="canActiveNextStep"></po-step>
<!-- After -->
<po-step p-label="Personal" [p-can-active-next-step="canActiveNextStep.bind(this)"></po-step>
// Correct way to pass functions in v2
actions: Array<PoPageAction> = [
{ label: 'Adicionar', action: this.add.bind(this) }
]