我使用 Material UI 的 TextField 作为组件。
import { FieldProps, getIn } from "formik";
import React from "react";
export const FormTextField: React.FC<FieldProps & TextFieldProps> = ({
error,
helperText,
field,
form,
...rest
}) => {
const isTouched = getIn(form.touched, field.name);
const errorMessage = getIn(form.errors, field.name);
return (
<TextField
variant="outlined"
fullWidth
error={error ?? Boolean(isTouched && errorMessage)}
helperText={
helperText ?? (isTouched && errorMessage ? errorMessage : undefined)
}
{...rest}
{...field}
/>
);
};
Run Code Online (Sandbox Code Playgroud)
当我运行pnpm lint时,它会抛出此错误:
错误:函数组件不是函数声明(react/function-component-definition)
我想使用这个组件,但找不到任何解决方案来解决它。它的解决方案是什么?请帮助我。谢谢
我在 Next.js 应用程序中使用 AWS Cognito 进行身份验证。以下是 next.js 中 AWS Cognito 的配置
\nimport { Auth, Amplify } from "aws-amplify";\n \nAmplify.configure({\n Auth: {\n mandatorySignId: false,\n region: config.cognito.REGION,\n userPoolId: config.cognito.USER_POOL_ID,\n userPoolWebClientId: config.cognito.APP_CLIENT_ID,\n oauth: {\n domain: config.cognito.DOMAIN,\n scope: ["email", "openid"],\n redirectSignIn: "http://localhost:3000/",\n redirectSignOut: "http://localhost:3000/",\n responseType: "code",\n },\n },\n});\n
Run Code Online (Sandbox Code Playgroud)\n该函数调用提交按钮:
\nimport { Auth, Amplify } from "aws-amplify";\n \nAmplify.configure({\n Auth: {\n mandatorySignId: false,\n region: config.cognito.REGION,\n userPoolId: config.cognito.USER_POOL_ID,\n userPoolWebClientId: config.cognito.APP_CLIENT_ID,\n oauth: {\n domain: config.cognito.DOMAIN,\n scope: ["email", "openid"],\n redirectSignIn: "http://localhost:3000/",\n redirectSignOut: "http://localhost:3000/",\n responseType: "code",\n },\n …
Run Code Online (Sandbox Code Playgroud)