Pre-alpha: React with any emoji, behind flag

This commit is contained in:
Ken Powers 2020-05-05 15:49:34 -04:00 committed by Scott Nonnenberg
parent d13c3d3350
commit 0865a5481c
31 changed files with 572 additions and 234 deletions

42
ts/util/hooks.ts Normal file
View file

@ -0,0 +1,42 @@
import * as React from 'react';
import { ActionCreatorsMapObject, bindActionCreators } from 'redux';
import { useDispatch } from 'react-redux';
// Restore focus on teardown
export const useRestoreFocus = (
// The ref for the element to receive initial focus
focusRef: React.RefObject<any>,
// Allow for an optional root element that must exist
root: boolean | HTMLElement | null = true
) => {
React.useEffect(() => {
if (!root) {
return;
}
const lastFocused = document.activeElement as any;
if (focusRef.current) {
focusRef.current.focus();
}
return () => {
// This ensures that the focus is returned to
// previous element
setTimeout(() => {
if (lastFocused && lastFocused.focus) {
lastFocused.focus();
}
});
};
}, [focusRef, root]);
};
export const useBoundActions = <T extends ActionCreatorsMapObject>(
actions: T
) => {
const dispatch = useDispatch();
return React.useMemo(() => {
return bindActionCreators(actions, dispatch);
}, [dispatch]);
};

View file

@ -11551,17 +11551,17 @@
"rule": "React-createRef",
"path": "ts/components/conversation/Message.tsx",
"line": " public audioRef: React.RefObject<HTMLAudioElement> = React.createRef();",
"lineNumber": 181,
"lineNumber": 184,
"reasonCategory": "usageTrusted",
"updated": "2020-04-16T19:36:47.586Z"
"updated": "2020-04-30T15:59:13.160Z"
},
{
"rule": "React-createRef",
"path": "ts/components/conversation/Message.tsx",
"line": " > = React.createRef();",
"lineNumber": 185,
"lineNumber": 188,
"reasonCategory": "usageTrusted",
"updated": "2020-04-16T19:36:47.586Z"
"updated": "2020-04-30T15:59:13.160Z"
},
{
"rule": "React-createRef",
@ -11784,4 +11784,4 @@
"reasonCategory": "falseMatch",
"updated": "2020-04-05T23:45:16.746Z"
}
]
]