Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

import React, {createContext, useContext, useRef, useCallback} from 'react';
import {UIManager, findNodeHandle} from 'react-native';
import React, { createContext, useContext, useRef, useCallback } from 'react';
import { UIManager, findNodeHandle } from 'react-native';

interface CheckoutEventContextType {
registerWebView: (webViewRef: React.RefObject<any>) => void;
unregisterWebView: () => void;
respondToEvent: (eventId: string, response: any) => Promise<boolean>;
respondToEvent: (eventId: string, response: any) => boolean;
}

const CheckoutEventContext = createContext<CheckoutEventContextType | null>(
Expand Down Expand Up @@ -52,7 +52,7 @@ export const ShopifyCheckoutEventProvider = ({
}, []);

const respondToEvent = useCallback(
async (eventId: string, response: any): Promise<boolean> => {
(eventId: string, response: any): boolean => {
if (!webViewRef.current?.current) {
return false;
}
Expand Down Expand Up @@ -112,11 +112,11 @@ export function useShopifyEvent(eventId: string) {
return {
id: eventId,
respondWith: useCallback(
async (response: any) => {
(response: any) => {
if (!eventContext) {
return false;
}
return await eventContext.respondToEvent(eventId, response);
return eventContext.respondToEvent(eventId, response);
},
[eventId, eventContext],
),
Expand Down
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,18 @@
"eslintConfig": {
"root": true,
"extends": "@react-native",
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-shadow": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/require-await": "error",
"no-console": "error"
}
}
}
}
4 changes: 2 additions & 2 deletions sample/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
android/build
android/app/build
android/
ios/
Loading