mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
161b910494
Summary: A few recent imports have explicitly added ".js" to the end of their path. This prevents Metro from resolving platform-specific JS files, e.g. "Foo.android.js" or "Foo.windows.js" instead of "Foo.js". React Native Windows provides its own implementation of files in a few cases where stock React Native will share them between Android and iOS. We hope to reduce/eliminate these long term, but requiring explicit ".js" files currently breaks us in a couple of places where we have custom implementations. This change is a quick regex replace of ES6 and CommonJS imports in 'Libraries/" to eliminate ".js". ## Changelog [General] [Fixed] - Do not explicitly include ".js" in Library imports Pull Request resolved: https://github.com/facebook/react-native/pull/28311 Test Plan: I haven't done any manual validation of this, but `flow-check` should catch any issues with this during CI. Reviewed By: cpojer Differential Revision: D20486466 Pulled By: TheSavior fbshipit-source-id: 31e1ccc307967417d7d09c34c859f0b2b69eac84
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
import Pressability, {
|
|
type EventHandlers,
|
|
type PressabilityConfig,
|
|
} from './Pressability';
|
|
import {useEffect, useRef} from 'react';
|
|
|
|
export default function usePressability(
|
|
config: PressabilityConfig,
|
|
): EventHandlers {
|
|
const pressabilityRef = useRef<?Pressability>(null);
|
|
if (pressabilityRef.current == null) {
|
|
pressabilityRef.current = new Pressability(config);
|
|
}
|
|
const pressability = pressabilityRef.current;
|
|
|
|
// On the initial mount, this is a no-op. On updates, `pressability` will be
|
|
// re-configured to use the new configuration.
|
|
useEffect(() => {
|
|
pressability.configure(config);
|
|
}, [config, pressability]);
|
|
|
|
// On unmount, reset pending state and timers inside `pressability`. This is
|
|
// a separate effect because we do not want to reset when `config` changes.
|
|
useEffect(() => {
|
|
return () => {
|
|
pressability.reset();
|
|
};
|
|
}, [pressability]);
|
|
|
|
return pressability.getEventHandlers();
|
|
}
|