src: use prop unpacking pattern

This makes the code a bit shorter by not having to use `props.` all of
the time. Also make everything VoidFunctionComponent while we are
touching this.
This commit is contained in:
David Lechner
2022-03-12 16:07:31 -06:00
parent 228ba4ebb8
commit 8e4045449c
18 changed files with 193 additions and 131 deletions
+3 -3
View File
@@ -127,7 +127,7 @@ type AppProps = {
onEditorChanged?: (editor: EditorType) => void;
};
const App: React.VoidFunctionComponent<AppProps> = (props) => {
const App: React.VoidFunctionComponent<AppProps> = ({ onEditorChanged }) => {
const darkMode = useSelector((s): boolean => s.settings.darkMode);
const showDocs = useSelector((s): boolean => s.settings.showDocs);
const [isDragging, setIsDragging] = useState(false);
@@ -139,8 +139,8 @@ const App: React.VoidFunctionComponent<AppProps> = (props) => {
setEditor: (editor) => {
setEditor(editor);
if (props.onEditorChanged) {
props.onEditorChanged(editor);
if (onEditorChanged) {
onEditorChanged(editor);
}
},
}),