Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/components/src/swipeable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ export const Swipeable = ( {
);

const getTouchEvents = useCallback( () => {
if ( typeof document === 'undefined' ) {
return null;
}
if ( 'onpointerup' in document ) {
return {
onPointerDown: handleDragStart,
Expand Down
20 changes: 5 additions & 15 deletions packages/i18n-calypso/src/rtl.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
import { createHigherOrderComponent } from '@wordpress/compose';
import { forwardRef, useContext, useMemo } from 'react';
import { useSubscription } from 'use-subscription';
import { forwardRef, useCallback, useContext, useSyncExternalStore } from 'react';
import I18NContext from './context';

export function useRtl() {
const i18n = useContext( I18NContext );
// Subscription object (adapter) for the `useSubscription` hook
const RtlSubscription = useMemo(
() => ( {
getCurrentValue() {
return i18n.isRtl();
},
subscribe( callback ) {
return i18n.subscribe( callback );
},
} ),
[ i18n ]
);

return useSubscription( RtlSubscription );
const getSnapshot = useCallback( () => i18n.isRtl(), [ i18n ] );
const subscribe = useCallback( ( callback ) => i18n.subscribe( callback ), [ i18n ] );

return useSyncExternalStore( subscribe, getSnapshot, getSnapshot );
}

export const withRtl = createHigherOrderComponent(
Expand Down
Loading