-
-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) ## Description This reverts commit e3e0b79. #2835 was the first PR that was meant to introduce compatibility with `Next.js`. Unfortunately, it broke types outside of our repository. Our `tsconfig.json` has special flag, i.e. `moduleSuffixes`, which allows `tsc` to look for `.native` files first. Most of our users do not have this flag and they've run into `ts` problems, like this one: ``` 'TextInput' refers to a value, but is being used as a type here. Did you mean 'typeof TextInput'? ``` Given that removing `moduleSuffixes` from `tsconfig` results in a bunch of errors (and there are more of them that we may not be aware of), we decided that it will be better to revert this change for now. It is not necessary since we only need it to support `Next.js`. At first I thought that #2873 may help, but unfortunately it doesn't. Fixes #2889 ## Test plan 1. Check that web, Android and iOS work as they did before 2. Check that code from [this comment](#2835 (comment)) now does not throw any errors
- Loading branch information
Showing
28 changed files
with
382 additions
and
389 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,5 @@ | ||
import React from 'react'; | ||
// Reexport the native module spec used by codegen. The relevant files are inluded on Android | ||
// to ensure the compatibility with the old arch, while iOS doesn't require those at all. | ||
|
||
import type { ActionType } from './ActionType'; | ||
import { isNewWebImplementationEnabled } from './EnableNewWebImplementation'; | ||
import { Gestures, HammerGestures } from './web/Gestures'; | ||
import type { Config } from './web/interfaces'; | ||
import InteractionManager from './web/tools/InteractionManager'; | ||
import NodeManager from './web/tools/NodeManager'; | ||
import * as HammerNodeManager from './web_hammer/NodeManager'; | ||
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; | ||
|
||
export default { | ||
handleSetJSResponder(tag: number, blockNativeResponder: boolean) { | ||
console.warn('handleSetJSResponder: ', tag, blockNativeResponder); | ||
}, | ||
handleClearJSResponder() { | ||
console.warn('handleClearJSResponder: '); | ||
}, | ||
createGestureHandler<T>( | ||
handlerName: keyof typeof Gestures, | ||
handlerTag: number, | ||
config: T | ||
) { | ||
if (isNewWebImplementationEnabled()) { | ||
if (!(handlerName in Gestures)) { | ||
throw new Error( | ||
`react-native-gesture-handler: ${handlerName} is not supported on web.` | ||
); | ||
} | ||
|
||
const GestureClass = Gestures[handlerName]; | ||
NodeManager.createGestureHandler( | ||
handlerTag, | ||
new GestureClass(new GestureHandlerWebDelegate()) | ||
); | ||
InteractionManager.getInstance().configureInteractions( | ||
NodeManager.getHandler(handlerTag), | ||
config as unknown as Config | ||
); | ||
} else { | ||
if (!(handlerName in HammerGestures)) { | ||
throw new Error( | ||
`react-native-gesture-handler: ${handlerName} is not supported on web.` | ||
); | ||
} | ||
|
||
// @ts-ignore If it doesn't exist, the error is thrown | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const GestureClass = HammerGestures[handlerName]; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
HammerNodeManager.createGestureHandler(handlerTag, new GestureClass()); | ||
} | ||
|
||
this.updateGestureHandler(handlerTag, config as unknown as Config); | ||
}, | ||
attachGestureHandler( | ||
handlerTag: number, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
newView: any, | ||
_actionType: ActionType, | ||
propsRef: React.RefObject<unknown> | ||
) { | ||
if ( | ||
!(newView instanceof HTMLElement || newView instanceof React.Component) | ||
) { | ||
return; | ||
} | ||
|
||
if (isNewWebImplementationEnabled()) { | ||
//@ts-ignore Types should be HTMLElement or React.Component | ||
NodeManager.getHandler(handlerTag).init(newView, propsRef); | ||
} else { | ||
//@ts-ignore Types should be HTMLElement or React.Component | ||
HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef); | ||
} | ||
}, | ||
updateGestureHandler(handlerTag: number, newConfig: Config) { | ||
if (isNewWebImplementationEnabled()) { | ||
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig); | ||
|
||
InteractionManager.getInstance().configureInteractions( | ||
NodeManager.getHandler(handlerTag), | ||
newConfig | ||
); | ||
} else { | ||
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig); | ||
} | ||
}, | ||
getGestureHandlerNode(handlerTag: number) { | ||
if (isNewWebImplementationEnabled()) { | ||
return NodeManager.getHandler(handlerTag); | ||
} else { | ||
return HammerNodeManager.getHandler(handlerTag); | ||
} | ||
}, | ||
dropGestureHandler(handlerTag: number) { | ||
if (isNewWebImplementationEnabled()) { | ||
NodeManager.dropGestureHandler(handlerTag); | ||
} else { | ||
HammerNodeManager.dropGestureHandler(handlerTag); | ||
} | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
flushOperations() {}, | ||
}; | ||
import Module from './specs/NativeRNGestureHandlerModule'; | ||
export default Module; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react'; | ||
|
||
import type { ActionType } from './ActionType'; | ||
import { isNewWebImplementationEnabled } from './EnableNewWebImplementation'; | ||
import { Gestures, HammerGestures } from './web/Gestures'; | ||
import type { Config } from './web/interfaces'; | ||
import InteractionManager from './web/tools/InteractionManager'; | ||
import NodeManager from './web/tools/NodeManager'; | ||
import * as HammerNodeManager from './web_hammer/NodeManager'; | ||
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate'; | ||
|
||
export default { | ||
handleSetJSResponder(tag: number, blockNativeResponder: boolean) { | ||
console.warn('handleSetJSResponder: ', tag, blockNativeResponder); | ||
}, | ||
handleClearJSResponder() { | ||
console.warn('handleClearJSResponder: '); | ||
}, | ||
createGestureHandler<T>( | ||
handlerName: keyof typeof Gestures, | ||
handlerTag: number, | ||
config: T | ||
) { | ||
if (isNewWebImplementationEnabled()) { | ||
if (!(handlerName in Gestures)) { | ||
throw new Error( | ||
`react-native-gesture-handler: ${handlerName} is not supported on web.` | ||
); | ||
} | ||
|
||
const GestureClass = Gestures[handlerName]; | ||
NodeManager.createGestureHandler( | ||
handlerTag, | ||
new GestureClass(new GestureHandlerWebDelegate()) | ||
); | ||
InteractionManager.getInstance().configureInteractions( | ||
NodeManager.getHandler(handlerTag), | ||
config as unknown as Config | ||
); | ||
} else { | ||
if (!(handlerName in HammerGestures)) { | ||
throw new Error( | ||
`react-native-gesture-handler: ${handlerName} is not supported on web.` | ||
); | ||
} | ||
|
||
// @ts-ignore If it doesn't exist, the error is thrown | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const GestureClass = HammerGestures[handlerName]; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call | ||
HammerNodeManager.createGestureHandler(handlerTag, new GestureClass()); | ||
} | ||
|
||
this.updateGestureHandler(handlerTag, config as unknown as Config); | ||
}, | ||
attachGestureHandler( | ||
handlerTag: number, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
newView: any, | ||
_actionType: ActionType, | ||
propsRef: React.RefObject<unknown> | ||
) { | ||
if ( | ||
!(newView instanceof HTMLElement || newView instanceof React.Component) | ||
) { | ||
return; | ||
} | ||
|
||
if (isNewWebImplementationEnabled()) { | ||
//@ts-ignore Types should be HTMLElement or React.Component | ||
NodeManager.getHandler(handlerTag).init(newView, propsRef); | ||
} else { | ||
//@ts-ignore Types should be HTMLElement or React.Component | ||
HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef); | ||
} | ||
}, | ||
updateGestureHandler(handlerTag: number, newConfig: Config) { | ||
if (isNewWebImplementationEnabled()) { | ||
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig); | ||
|
||
InteractionManager.getInstance().configureInteractions( | ||
NodeManager.getHandler(handlerTag), | ||
newConfig | ||
); | ||
} else { | ||
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig); | ||
} | ||
}, | ||
getGestureHandlerNode(handlerTag: number) { | ||
if (isNewWebImplementationEnabled()) { | ||
return NodeManager.getHandler(handlerTag); | ||
} else { | ||
return HammerNodeManager.getHandler(handlerTag); | ||
} | ||
}, | ||
dropGestureHandler(handlerTag: number) { | ||
if (isNewWebImplementationEnabled()) { | ||
NodeManager.dropGestureHandler(handlerTag); | ||
} else { | ||
HammerNodeManager.dropGestureHandler(handlerTag); | ||
} | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
flushOperations() {}, | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const RNRenderer = { | ||
findHostInstance_DEPRECATED: (_ref: any) => null, | ||
}; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
export { default as RNRenderer } from 'react-native/Libraries/Renderer/shims/ReactNative'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const RNRenderer = { | ||
findHostInstance_DEPRECATED: (_ref: any) => null, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.