auto-compile-setting.tsx 938 B

12345678910111213141516171819202122232425262728293031
  1. import ToggleSetting from '../toggle-setting'
  2. import { useTranslation } from 'react-i18next'
  3. import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
  4. import { useCallback } from 'react'
  5. import * as eventTracking from '../../../../../infrastructure/event-tracking'
  6. export default function AutoCompileSetting() {
  7. const { autoCompile, setAutoCompile } = useCompileContext()
  8. const { t } = useTranslation()
  9. const sendEventAndSet = useCallback(
  10. (value: boolean) => {
  11. eventTracking.sendMB('recompile-setting-changed', {
  12. setting: 'auto-compile',
  13. settingVal: value,
  14. })
  15. setAutoCompile(value)
  16. },
  17. [setAutoCompile]
  18. )
  19. return (
  20. <ToggleSetting
  21. id="autoCompile"
  22. label={t('autocompile')}
  23. description={t('automatically_recompile_the_project_as_you_edit')}
  24. checked={autoCompile}
  25. onChange={sendEventAndSet}
  26. />
  27. )
  28. }