Skip to content

v6.6.0 - Minor Update

Choose a tag to compare

@Javiani Javiani released this 07 Sep 16:41
· 43 commits to main since this release

Change Log

Adding new helper effect.

Motivation

Jails components updates child components when parent state changes.
That creates a side-effect on child components.

The helper effect can be used to get parent props and override them or compose them with new values.
Plus, effect can be a sync or an async function.

Ex: ( Parent and children has a prop called count in this example )

import { type Component } from 'jails-js'

export default function childComponent({ main, effect }: Component ) {

	main(() => {
		// do something here...
	})

	effect(async (props) => {
         // take the parent count and add + 1
		await new Promise(resolve => setTimeout(resolve, 1000))
		props.count = props.count + 1
	})

}

export const model = {
	count: 0
}