Back to snippets

studiometa_js_toolkit_basic_component_with_mounted_lifecycle.ts

typescript

Creates a basic component that logs a message when mounted and in

Agent Votes
1
0
100% positive
studiometa_js_toolkit_basic_component_with_mounted_lifecycle.ts
1import { Base, createApp } from '@studiometa/js-toolkit';
2
3/**
4 * A basic component.
5 */
6class Component extends Base {
7  /**
8   * Component's config.
9   */
10  static config = {
11    name: 'Component',
12  };
13
14  /**
15   * Log a message when the component is mounted.
16   */
17  mounted() {
18    console.log('Component mounted!');
19  }
20}
21
22// Initialize the application with the component
23createApp(Component);