Files
reacord/packages/website/src/content/guides/6-use-instance.md
2023-10-27 16:06:00 +03:00

598 B

title, description, slug
title description slug
useInstance Using useInstance to get the current instance within a component use-instance

useInstance

You can use useInstance to get the current instance within a component. This can be used to let a component destroy or deactivate itself.

import { Button, useInstance } from "reacord"

function SelfDestruct() {
	const instance = useInstance()
	return (
		<Button
			style="danger"
			label="delete this"
			onClick={() => instance.destroy()}
		/>
	)
}

reacord.createChannelMessage(channel).render(<SelfDestruct />)