#onTouchStart not being working
1 messages · Page 1 of 1 (latest)
Astro, by default, does not ship JavaScript for components, which includes event listeners like onTouchStart. To enable interactivity in your components, you need to use a client:* directive.
For example, if you're using React, you can use client:load or client:visible to hydrate your component when it loads or becomes visible, respectively. Here's an example:
<MyComponent client:load />
This will ensure that your component is hydrated with React on the client-side, and all event listeners should work as expected.
If you're already using a client:* directive and onTouchStart is still not working, there might be a bug. In that case, you should open an issue (https://github.com/withastro/astro/issues) on the Astro GitHub repository.
For more information, you can refer to the "Hydrating Interactive Components" (https://docs.astro.build/en/core-concepts/framework-components/#hydrating-interactive-components) section in the Astro documentation.