小编Net*_*nin的帖子

如何解决 Eslint - Module.createRequire is not a function 错误?

我正在将 React 应用程序与 Parcel 捆绑器和 TypeScript 结合使用。我正在尝试使用 ESLint 但出现此错误:

ESLint:初始化错误(ESLint)。Module.createRequire 不是函数。

版本:

  • IDE:网络风暴
  • 节点版本:16.6.2
  • NPM版本:7.20.3
  • 我的机器上没有全局安装 ESLint

这是我的设置:

包.json:

{
  "name": "app-boilerplate",
  "version": "1.0.0",
  "description": "",
  "source": "public/index.html",
  "scripts": {
    "start": "parcel --port=3000 --open --lazy",
    "build": "parcel build",
    "lint": "eslint . --ext .tsx,.ts",
    "lint:fix": "eslint . --ext .tsx,.ts --fix",
    "test": "jest --coverage --passWithNoTests",
    "test:watch": "jest --watchAll --coverage",
    "prepare": "husky install",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@babel/core": "^7.16.7",
    "@parcel/transformer-svg-react": "^2.2.0",
    "@storybook/addon-actions": "^6.4.13",
    "@storybook/addon-essentials": …
Run Code Online (Sandbox Code Playgroud)

javascript parcel typescript reactjs eslint

27
推荐指数
1
解决办法
2万
查看次数

如何访问 Yup 模式中的上下文

我正在使用react-hook-formYup来管理我的应用程序中的表单。

我正在尝试根据我的组件状态创建动态 Yup 模式。

例如:

import React, { useContext } from "react";
import { useForm } from "react-hook-form";
import { useHistory } from "react-router-dom";
import { FirstFormContext } from "../context/FirstFormContext";
import { SecondFormContext } from "../context/SecondFormContext";
import { yupResolver } from "@hookform/resolvers/yup";
import * as yup from "yup";

const schema = yup.object().shape({
  email: yup.string().email().min(2), // <-- Here I want to access the value
  address: yup.string().min(2).max(20)
});

const SecondForm = () => {
  const { secondFormData, setSecondFormData …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs yup react-hook-form

11
推荐指数
1
解决办法
1万
查看次数

如何在 Material UI 版本 5 中配置 RTL(从右到左)支持

我将应用程序Material-UI从版本 4 更新到版本 5,但 RTL 支持不再起作用。

我查看了文档并按照每个步骤进行操作:

https://mui.com/guides/right-to-left/

实际结果是应用程序仍然是 LTR(您可以查看TextField下面 Codesandbox 链接中的组件)。

预期结果是应用程序应该是 RTL。

尽管如此,RTL 支持仍然不起作用。

此外,我在以下位置创建了一个示例版本Codesandbox

https://codesandbox.io/s/issue-with-rtl-in-material-ui-v5-jtii6?file=/src/index.js

我将感谢您帮助找出问题所在。

谢谢。

javascript reactjs material-ui

8
推荐指数
1
解决办法
4466
查看次数

使用react-hook-form重置功能时,Material-UI Checkbox不会重置

我在用着

"react-hook-form": "7.9.0",

"@material-ui/core": "4.11.4",

我试图通过单击常规按钮并使用 的reset( react-hook-form reset ) 方法来手动重置某些复选框react-hook-form

由于某种原因,我可以在 React 开发工具中看到“checked”属性更改为 false,但 SwitchBase(v 图标)仍然打开。

你可以看到例子:在这里

感谢您的时间。

javascript reactjs material-ui react-hook-form

3
推荐指数
1
解决办法
5251
查看次数