Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useMutation(
mutation: MutationNode,
userConfig: MutationConfig = {},
/** if not provided, the context environment will be used. */
environment?: Environment,
): [Mutate, MutationState] {
const [state, setState] = useState>({
loading: false,
data: null,
error: null,
});
const isMounted = useMounted();
const relayContext = useContext(ReactRelayContext);
const resolvedEnvironment = environment || relayContext!.environment;
const {
configs,
variables,
uploadables,
onCompleted,
onError,
optimisticUpdater,
optimisticResponse,
updater,
} = userConfig;
const mutate: Mutate = useCallback(
config => {
export default function useFocusManager(ref, props = {}, opts = {}) {
const isMounted = useMounted()
const [focused, setFocus] = useState(false)
const events = useFocusManagerBase({
...opts,
onChange: focused => {
if (isMounted()) setFocus(focused)
},
isDisabled: () =>
props.disabled === true || isInDisabledFieldset(ref.current),
didHandle(focused, event) {
let handler = props[focused ? 'onFocus' : 'onBlur']
if (handler) handler(event)
if (opts.didHandle && !event.isWidgetDefaultPrevented)
opts.didHandle(focused, event)
},
export default function useScrollManager(
ref,
onMove,
getScrollParent = list => list.parentNode,
) {
let isMounted = useMounted()
const stateBagRef = useRef({})
function handleScroll(selected, list, nextFocused) {
if (!isMounted()) return
const stateBag = stateBagRef.current
let lastVisible = stateBag.currentVisible
let lastItem = stateBag.currentFocused
let shown, changed
stateBag.currentVisible = !(!list.offsetWidth || !list.offsetHeight)
stateBag.currentFocused = nextFocused
changed = lastItem !== nextFocused
shown = stateBag.currentVisible && !lastVisible
export function useMutation(
mutation: MutationNode,
userConfig: MutationConfig = {},
/** if not provided, the context environment will be used. */
environment?: Environment,
): [Mutate, MutationState] {
const [state, setState] = useState>({
loading: false,
data: null,
error: null,
});
const isMounted = useMounted();
const relayContext: any = useContext(ReactRelayContext);
const resolvedEnvironment = environment || relayContext.environment;
const {
configs,
variables,
uploadables,
onCompleted,
onError,
optimisticUpdater,
optimisticResponse,
updater,
} = userConfig;
const mutate: Mutate = useCallback(
(config) => {