
ctrl+k
Enter a search term above to see results...
Enter a search term above to see results...
Reactivity is the heart of Semantic UI components. This lesson introduces you to reactive state management using signals - automatically updating your UI when data changes.
The defaultState
object defines your component’s reactive properties. When these values change, your template automatically updates to reflect the new data.
Looking at component.js, you’ll notice:
defaultState
initializes a counter and toggle property.set()
to update values in event handlers.get()
to access values in JavaScript codeThe framework provides special methods for common state operations:
.increment()
and .decrement()
for numbers.toggle()
for booleans.now()
for dates (updates to current time).push()
, .removeIndex()
, .setIndex()
In the component.html template:
.get()
: {count}
{isEven(count)}
Enhance the counter component to include:
Hint: You’ll need to add a new state property and method, and update the template to use them.