Effect Mount Increment

Increment state once on mount to prove effects run without user input.

Effect: mount + inc

Count =

Should read 13 on first paint.

PHP
<?php // model $cnt = state(0); // UI + Effect // // Expectation: After mount, $cnt becomes 1 without any user interaction. $app = fragment([ el('div', [attrs(['class' => 'container p-3'])], [ el('h1', [], [ text('Effect: mount + inc') ]), el('p', [], [ text(concat('Count = ', read($cnt))) ]), el('p', [cls('text-muted')], [ text('Should read 13 on first paint.') ]), ]), // EFFECT: on mount, increment the counter once onMount([ inc($cnt, 13, true) ]), ]);