# code-snippets/3.10.0/js/components/EditorSidebar/controls/ActivationSwitch.tsx

Code Snippets, version 3.10.0. 38 lines.

- Page: https://pluginprobe.com/plugins/code-snippets/3.10.0/code/js/components/EditorSidebar/controls/ActivationSwitch.tsx
- Raw: https://pluginprobe.com/plugins/code-snippets/3.10.0/raw/js/components/EditorSidebar/controls/ActivationSwitch.tsx
- Modified: 2025-08-29T08:54:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/code-snippets/3.10.0/code/js/components/EditorSidebar/controls/ActivationSwitch.tsx#L10-L20`.

```tsx
import React from 'react'
import { __ } from '@wordpress/i18n'
import { useSnippetForm } from '../../../hooks/useSnippetForm'
import { SubmitSnippetAction, useSubmitSnippet } from '../../../hooks/useSubmitSnippet'
import { handleUnknownError } from '../../../utils/errors'

export const ActivationSwitch = () => {
	const { snippet, isWorking } = useSnippetForm()
	const { submitSnippet } = useSubmitSnippet()

	return (
		<div className="inline-form-field activation-switch-container">
			<h4>{__('Status')}</h4>

			<label>
				{snippet.active
					? __('Active', 'code-snippets')
					: __('Inactive', 'code-snippets')}

				<input
					id="activation-switch"
					type="checkbox"
					checked={snippet.active}
					disabled={isWorking || !!snippet.shared_network}
					className="switch"
					onChange={() => {
						submitSnippet(snippet.active
							? SubmitSnippetAction.SAVE_AND_DEACTIVATE
							: SubmitSnippetAction.SAVE_AND_ACTIVATE)
							.then(() => undefined)
							.catch(handleUnknownError)
					}}
				/>
			</label>
		</div>
	)
}

```
