x-effect
x-effect is a useful directive for re-evaluating an expression when one of its dependencies change. It is very similar to useEffect hook in React.
<div x-data="{ label: 'Hello' }" x-effect="console.log(label)">
<button @click="label += ' World!'">Change Message</button>
</div>
When this component is loaded, the
x-effectexpression will be run and "Hello" will be logged into the console.
Because Alpine knows about any property references contained within
x-effect, when the button is clicked andlabelis changed, the effect will be re-triggered and "Hello World!" will be logged to the console.
x-transition
Alpine provides a robust transitions utility out of the box. With the help of x-transition directive, you can create smooth transitions between when an element is shown or hidden.
x-ignore
By default, Alpine will crawl and initialize the entire DOM tree of an element containing x-init or x-data.
