Lightning Web コンポーネントがロードされたときにカスタムロジックを実行できる手法はどれですか?
正解:B
In Lightning Web Components (LWC), the component lifecycle is managed by standard Web Component lifecycle hooks. To run logic exactly once when the component is inserted into the Document Object Model (DOM), a developer should use the connectedCallback() method (Option B). The connectedCallback() is the LWC equivalent of Aura's init event. It is the ideal place to: * Perform initial data fetching (via imperative Apex). * Initialize internal state or variables. * Subscribe to a Lightning Message Service (LMS) channel. * Establish communication with the parent component. Option A and D are Aura-specific syntax and are not valid in LWC. Option C (renderedCallback()) runs every time the component finishes a render cycle. Because a component can re-render many times (whenever a reactive property changes), placing initialization logic in renderedCallback can lead to performance issues or infinite loops if not guarded carefully. Therefore, connectedCallback() is the standard, most efficient way to handle "on load" logic in LWC.