mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 17:45:22 +00:00
reducers: use typed useSelector hook
This refactors the code to use a typed useSelector() hook.
This commit is contained in:
@@ -12,10 +12,10 @@ import tomorrowNightEightiesTheme from 'monaco-themes/themes/Tomorrow-Night-Eigh
|
||||
import xcodeTheme from 'monaco-themes/themes/Xcode_default.json';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import MonacoEditor, { monaco } from 'react-monaco-editor';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { IDisposable } from 'xterm';
|
||||
import { compile } from '../mpy/actions';
|
||||
import { RootState } from '../reducers';
|
||||
import { useSelector } from '../reducers';
|
||||
import { toggleBoolean } from '../settings/actions';
|
||||
import { BooleanSettingId } from '../settings/defaults';
|
||||
import { isMacOS } from '../utils/os';
|
||||
@@ -63,7 +63,7 @@ const xcodeId = 'xcode';
|
||||
monaco.editor.defineTheme(xcodeId, xcodeTheme as monaco.editor.IStandaloneThemeData);
|
||||
|
||||
const contextMenu = (_props: ContextMenu2ContentProps): JSX.Element => {
|
||||
const editor = useSelector((state: RootState) => state.editor.current);
|
||||
const editor = useSelector((s) => s.editor.current);
|
||||
|
||||
const [i18n] = useI18n({ id: 'editor', translations: { en }, fallback: en });
|
||||
|
||||
@@ -143,7 +143,7 @@ const Editor: React.FunctionComponent = (_props) => {
|
||||
return () => window.removeEventListener('storage', onStorage);
|
||||
});
|
||||
|
||||
const darkMode = useSelector((state: RootState) => state.settings.darkMode);
|
||||
const darkMode = useSelector((s) => s.settings.darkMode);
|
||||
|
||||
const [i18n] = useI18n({ id: 'editor', translations: { en }, fallback: en });
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Copyright (c) 2020-2021 The Pybricks Authors
|
||||
|
||||
import React from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import * as notificationActions from '../notifications/actions';
|
||||
import { RootState } from '../reducers';
|
||||
import { useSelector } from '../reducers';
|
||||
import OpenFileButton, { OpenFileButtonProps } from '../toolbar/OpenFileButton';
|
||||
import { TooltipId } from '../toolbar/i18n';
|
||||
import * as editorActions from './actions';
|
||||
@@ -13,7 +13,7 @@ import openIcon from './open.svg';
|
||||
type OpenButtonProps = Pick<OpenFileButtonProps, 'id'>;
|
||||
|
||||
const OpenButton: React.FunctionComponent<OpenButtonProps> = (props) => {
|
||||
const editor = useSelector((state: RootState) => state.editor.current);
|
||||
const editor = useSelector((s) => s.editor.current);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// Copyright (c) 2020-2021 The Pybricks Authors
|
||||
|
||||
import React from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import * as editorActions from '../editor/actions';
|
||||
import { RootState } from '../reducers';
|
||||
import { useSelector } from '../reducers';
|
||||
import ActionButton, { ActionButtonProps } from '../toolbar/ActionButton';
|
||||
import { TooltipId } from '../toolbar/i18n';
|
||||
import downloadIcon from './save.svg';
|
||||
@@ -13,7 +13,7 @@ type SaveAsButtonProps = Pick<ActionButtonProps, 'id'> &
|
||||
Pick<ActionButtonProps, 'keyboardShortcut'>;
|
||||
|
||||
const SaveAsButton: React.FunctionComponent<SaveAsButtonProps> = (props) => {
|
||||
const editor = useSelector((state: RootState) => state.editor.current);
|
||||
const editor = useSelector((s) => s.editor.current);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user