小编Sar*_* UK的帖子

未知的生命周期阶段"mvn".您必须以<plugin-prefix>:<goal>或<plugin-group-id>格式指定有效的生命周期阶段或目标

通过eclipse构建sprint启动应用程序时出现此错误.

[错误]未知生命周期阶段"mvn".您必须以以下格式指定有效的生命周期阶段或目标:或:[:]:.可用的生命周期阶段包括:验证,初始化,生成源,流程源,生成资源,流程资源,编译,流程类,生成测试源,流程测试源,生成测试资源,流程-test-resources,test-compile,process-test-classes,test,prepare-package,package,pre-integration-test,integration-test,post-integration-test,verify,install,deploy,pre-clean,clean ,后清理,前期网站,网站,后期网站,网站部署. - > [Help 1] [ERROR] [ERROR]要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven.

但如果我通过命令提示符构建工作正常.附上下面的pom.xml.

的pom.xml

[ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, …
Run Code Online (Sandbox Code Playgroud)

maven spring-boot

18
推荐指数
4
解决办法
8万
查看次数

用于从字符串创建 JSX 元素的正确 TypeScript 类型

我有一个组件,我想默认将其呈现为h2. 如果他们愿意,我希望消费者能够指定不同的元素。下面的代码导致错误:

TS2604 - JSX element type 'ElementType' does not have any construct or call signatures

我想我明白为什么它会失败,TS 期望渲染一个 React 节点。为清楚起见,只要变量以大写字母开头(这是 JSX 要求),React能够呈现作为字符串引用的元素。我之前在 vanilla JS + React 中成功做到了这一点,我只是不知道如何满足 TypeScript。

我怎样才能让 TypeScript 在不诉诸于的情况下呈现这个 elementType?: any

import React, {ReactNode} from 'react'

interface Props {
    children: ReactNode;
    elementType?: string;
}

export default function ({children, elementType: ElementType = 'h2'}: Props): JSX.Element {
    return (
        <ElementType>{children}</ElementType>
    );
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

14
推荐指数
3
解决办法
2万
查看次数

如何在 redux 工具包中模拟 store

import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { render, screen, fireEvent } from '@testing-library/react';
import MyApp from './MyApp ';

const initialState = {};
const mockStore = configureStore(initialState);

describe('<MyApp />', () => {
  it('click button and shows modal', () => {
    render(
      <Provider store={mockStore}>
        <MyApp />
      </Provider>
    );

    fireEvent.click(screen.getByText('ADD MIOU'));
    expect(queryByText('Add MIOU Setting')).toBeInTheDocument();
  });
});
Run Code Online (Sandbox Code Playgroud)

我正在使用 jest 和 redux 工具包reactjs,并尝试模拟商店来编写测试。但出现以下错误

类型错误:store.getState 不是函数

有没有什么办法解决这一问题?我错过了什么吗?

reactjs redux react-testing-library

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

使用react-testing-library在Jest中模拟React上下文提供者

我有一个相当复杂的上下文,我将其包装在我的应用程序中来处理身份验证并提供从身份验证服务检索到的关联数据。我想绕过提供程序的所有功能并仅模拟返回值。当上下文呈现时,它会执行一堆我在测试时不希望发生的初始化函数。

我在我的包装函数中尝试了类似的方法:

const mockValue = {
  error: null,
  isAuthenticated: true,
  currentUser: 'phony',
  login: jest.fn(),
  logout: jest.fn(),
  getAccessToken: jest.fn(),
}

const MockAuthContext = () => ( React.createContext(mockValue) )

jest.mock("../contexts/AuthContext", () => ({
  __esModule: true,
  namedExport: jest.fn(),
  default: jest.fn(),
}));

beforeAll(() => {
  AuthContext.mockImplementation(MockAuthContext);
});

const customRender = (ui, { ...renderOpts } = {}) => {
  const ProviderWrapper = ({ children }) => (
      <AuthContext.Provider>
         {children}
      </AuthContext.Provider>
  );
  return render(ui, { wrapper: ProviderWrapper, ...renderOpts });
};

// re-export everything
export * from …
Run Code Online (Sandbox Code Playgroud)

mocking reactjs jestjs react-context react-testing-library

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

懒惰的渲染孩子

看看这个简单的例子:

 const List = function({ loading, entity }) {
    return (
        <Layout loading={loading}>
            <span>Name: {entity.name}</span>
        </Layout>
    );
};
Run Code Online (Sandbox Code Playgroud)

Layout组件children仅在loadingis时呈现false。但这里的问题是立即React解决Layout儿童问题。由于entitynull(while loading=true),我收到无法读取name的错误null。有没有一种简单的方法可以避免这个错误,因为它span总是会在entity不是时呈现null

目前我知道 3 个选项:

  1. 移动此spanstateless function接收entity作为prop
  2. 总结全childrenLayoutfunction后支持function childrenLayout
  3. 只需使用 {entity && <span>Name: {entity.name}</span>}

为什么我必须使用这些选项之一,我可以在渲染之前将React它们children视为函数并在内部解析块吗?

null components children lazy-evaluation reactjs

9
推荐指数
1
解决办法
1053
查看次数

泛型 - 下限/上限外卡行为?

我试图了解低级和上级通配符的行为.

尝试编译以下代码时遇到问题.

Collection<? extends Object> c = new ArrayList<Object>();
c.add(new Object()); // Compile time error
Run Code Online (Sandbox Code Playgroud)

为了解决这个问题,我也尝试了下限外卡.幸运或不幸的是,代码编译得很好但却造成了很多混乱.

Collection<? super Object> c = new ArrayList<Object>();
 c.add(new Object()); // Compiles fine
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下,这两个代码片段是如何工作的.如果有人可以提供其他示例/链接,那就太好了.

如果我上面做错了,请纠正我.

提前致谢.

java generics

7
推荐指数
1
解决办法
591
查看次数

material-table 和 reactjs 中自定义分页的任何示例

自定义分页的任何示例?材料表和reactjs。我想将页面大小传递给服务器,并且需要隐藏分页中的第一个和最后一个按钮

pagination material-table

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

CSS 运动路径 onClick

我需要有关已上传到codepen 的CSS 和 javascript 代码的帮助。

我正在尝试使用 CSS 运动路径,我希望能够使用 JavaScript 来控制它,因此当您按下“前进按钮”时,它会运行到最后一个关键帧并且有效,但是当我按下“后退按钮”时没发生什么事。我会喜欢它移回第一个关键帧。

问题是我的代码是否在正确的轨道上?我需要改变什么?

function myForwardFunction() {
  document.getElementById("pathed").style.animationPlayState = "running";
}

function myBackFunction() {
  document.getElementById("pathed").style.animationDirection = "reverse";
}
Run Code Online (Sandbox Code Playgroud)
section {
  width: 244px;
  height: 200px;
  border: 2px dashed lightgrey;
}

body {
  display: flex;
  padding: 10px;
  flex-wrap: wrap;
  gap: 30px;
  margin: 0;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

div {
  width: 50px;
  height: 50px;
  border: 1px solid hsl(343, 100%, 58%, .3);
  border-right: 5px solid hsl(343, 100%, 58%);
  background: hsla(343, 100%, 58%, …
Run Code Online (Sandbox Code Playgroud)

html javascript css

7
推荐指数
2
解决办法
237
查看次数

react-vis 示例中的暗区

我正在尝试使用 react-vis。如果我使用 privided 示例,我会在线条之间看到黑色区域。我想念什么?

在此处输入图片说明

reactjs react-vis

6
推荐指数
2
解决办法
2858
查看次数

在 React 中 npm run build 后没有 service-worker.js 文件

运行后npm run devbuild 文件夹中没有 service-worker.js 文件。

我也在serviceWorker.register()index.js 中 进行了更改
,我也在这个项目中使用firebase。

这是package.json文件

{
  "name": "movie",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "axios": "^0.20.0",
    "email-verifier": "^0.4.1",
    "firebase": "^7.24.0",
    "history": "^5.0.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-lottie": "^1.2.3",
    "react-router-dom": "^5.2.0",
    "react-scripts": "^4.0.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs progressive-web-apps create-react-app

6
推荐指数
1
解决办法
4489
查看次数