Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove lint warnings #1272

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
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
2 changes: 0 additions & 2 deletions account-kit/rn-signer/example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const path = require("path");
const { getDefaultConfig } = require("@react-native/metro-config");
const { getConfig } = require("react-native-builder-bob/metro-config");
const pkg = require("../package.json");
Comment on lines -3 to -4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this not used? cc @iykazrji


const rnSignerRoot = path.resolve(__dirname, "..");
const projectRoot = __dirname;
Expand Down
60 changes: 33 additions & 27 deletions account-kit/rn-signer/example/src/screens/magic-link-auth.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable import/extensions */
import { RNAlchemySigner } from "@account-kit/react-native-signer";
import type { User } from "@account-kit/signer";
import { useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
import {
Linking,
StyleSheet,
Expand All @@ -20,48 +20,54 @@ export default function MagicLinkAuthScreen() {
const [email, setEmail] = useState<string>("");
const [user, setUser] = useState<User | null>(null);

const handleUserAuth = ({ bundle }: { bundle: string }) => {
signer
.authenticate({
bundle,
type: "email",
})
.then(setUser)
.catch(console.error);
};
const handleUserAuth = useCallback(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moldy530 is this refactor okay? there were lint warnings here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine to me cc @iykazrji

({ bundle }: { bundle: string }) => {
signer
.authenticate({
bundle,
type: "email",
})
.then(setUser)
.catch(console.error);
},
[signer]
);

const handleIncomingURL = (event: { url: string }) => {
const regex = /[?&]([^=#]+)=([^&#]*)/g;
const handleIncomingURL = useCallback(
(event: { url: string }) => {
const regex = /[?&]([^=#]+)=([^&#]*)/g;

let params: Record<string, string> = {};
let match: RegExpExecArray | null;
let params: Record<string, string> = {};
let match: RegExpExecArray | null;

while ((match = regex.exec(event.url))) {
if (match[1] && match[2]) {
params[match[1]] = match[2];
while ((match = regex.exec(event.url))) {
if (match[1] && match[2]) {
params[match[1]] = match[2];
}
}
}

if (!params.bundle || !params.orgId) {
return;
}
if (!params.bundle || !params.orgId) {
return;
}

handleUserAuth({
bundle: params.bundle ?? "",
});
};
handleUserAuth({
bundle: params.bundle ?? "",
});
},
[handleUserAuth]
);

useEffect(() => {
// get the user if already logged in
signer.getAuthDetails().then(setUser);
}, []);
}, [signer]);

// Add listener for incoming links
useEffect(() => {
const subscription = Linking.addEventListener("url", handleIncomingURL);

return () => subscription.remove();
}, []);
}, [handleIncomingURL]);

return (
<View style={styles.container}>
Expand Down
Loading