Skip to content

Commit 7da9e8d

Browse files
removing unnecessary functionality
1 parent 0260179 commit 7da9e8d

5 files changed

Lines changed: 10 additions & 227 deletions

File tree

example/src/app/connect.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export default function Connect() {
4747
onMemberConnected={(payload) => {
4848
console.log(`Member connected with payload: ${JSON.stringify(payload)}`)
4949
}}
50+
onOAuthError={(payload) => {
51+
console.log(`OAuth error with payload: ${JSON.stringify(payload)}`)
52+
}}
5053
onOAuthRequested={(payload) => {
5154
console.log(`OAuth requested with URL: ${payload.url}`)
5255
}}

src/components/ConnectWidgets.test.tsx

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/components/ConnectWidgets.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import {
77
import { Type, SsoUrlProps, ConnectWidgetConfigurationProps } from "../sso"
88
import * as WebBrowser from "expo-web-browser"
99
import { makeWidgetComponentWithDefaults } from "./make_component"
10-
import { useOAuthDeeplink, OAuthProps } from "./oauth"
11-
import { useWidgetRendererWithRef, StylingProps } from "./renderer"
10+
import { StylingProps, useWidgetRenderer } from "./renderer"
1211

1312
export type ConnectWidgetProps = SsoUrlProps &
1413
StylingProps &
15-
OAuthProps &
1614
ConnectPostMessageCallbackProps<string> &
1715
ConnectWidgetConfigurationProps &
1816
JSX.IntrinsicAttributes
@@ -40,12 +38,10 @@ export function ConnectWidget(props: ConnectWidgetProps) {
4038
onOAuthRequested,
4139
}
4240

43-
const [ref, elem] = useWidgetRendererWithRef(
41+
const elem = useWidgetRenderer(
4442
{ ...modifiedProps, widgetType: Type.ConnectWidget },
4543
dispatchConnectLocationChangeEvent,
4644
)
4745

48-
useOAuthDeeplink(ref, modifiedProps)
49-
5046
return elem
5147
}

src/components/oauth.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/components/renderer.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, MutableRefObject, ReactElement } from "react"
1+
import React, { ReactElement } from "react"
22
import { StyleProp, ViewStyle, View } from "react-native"
33
import { WebView } from "react-native-webview"
44
import { Payload } from "@mxenabled/widget-post-message-definitions"
@@ -13,28 +13,18 @@ export type StylingProps = {
1313
webViewStyle?: StyleProp<ViewStyle>
1414
}
1515

16-
type MaybeWebViewRef = MutableRefObject<WebView | null>
1716
type BaseProps<Configuration> = Props<Configuration> & StylingProps
1817

1918
export function useWidgetRenderer<Configuration>(
2019
props: BaseProps<Configuration>,
2120
dispatchEvent: (url: string, callbacks: BaseProps<Configuration>) => Payload | undefined,
2221
): ReactElement {
23-
const [_ref, elem] = useWidgetRendererWithRef(props, dispatchEvent)
24-
return elem
25-
}
26-
27-
export function useWidgetRendererWithRef<Configuration>(
28-
props: BaseProps<Configuration>,
29-
dispatchEvent: (url: string, callbacks: BaseProps<Configuration>) => Payload | undefined,
30-
): [MaybeWebViewRef, ReactElement] {
31-
const ref = useRef<WebView>(null)
3222
const url = useSsoUrl(props)
3323
const fullscreenStyles = useFullscreenStyles()
3424
const style = props.style || fullscreenStyles
3525

3626
if (!url) {
37-
return [ref, <View style={style} />]
27+
return <View style={style} />
3828
}
3929

4030
const handler = makeRequestInterceptor(url, {
@@ -47,13 +37,11 @@ export function useWidgetRendererWithRef<Configuration>(
4737
window.MXReactNativeSDKVersion = "${sdkVersion}";
4838
`
4939

50-
return [
51-
ref,
40+
return (
5241
<View testID="widget_view" style={style}>
5342
<WebView
5443
testID="widget_webview"
5544
style={props.webViewStyle}
56-
ref={ref}
5745
scrollEnabled={true}
5846
source={{ uri: url }}
5947
originWhitelist={["*"]}
@@ -68,6 +56,6 @@ export function useWidgetRendererWithRef<Configuration>(
6856
onShouldStartLoadWithRequest={handler}
6957
onError={props.onWebViewError}
7058
/>
71-
</View>,
72-
]
59+
</View>
60+
)
7361
}

0 commit comments

Comments
 (0)