通过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.
[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) 我有一个组件,我想默认将其呈现为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) 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 不是函数
有没有什么办法解决这一问题?我错过了什么吗?
我有一个相当复杂的上下文,我将其包装在我的应用程序中来处理身份验证并提供从身份验证服务检索到的关联数据。我想绕过提供程序的所有功能并仅模拟返回值。当上下文呈现时,它会执行一堆我在测试时不希望发生的初始化函数。
我在我的包装函数中尝试了类似的方法:
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) 看看这个简单的例子:
const List = function({ loading, entity }) {
return (
<Layout loading={loading}>
<span>Name: {entity.name}</span>
</Layout>
);
};
Run Code Online (Sandbox Code Playgroud)
Layout
组件children
仅在loading
is时呈现false
。但这里的问题是立即React
解决Layout
儿童问题。由于entity
是null
(while loading=true
),我收到无法读取name
的错误null
。有没有一种简单的方法可以避免这个错误,因为它span
总是会在entity
不是时呈现null
?
目前我知道 3 个选项:
span
以stateless function
接收entity
作为prop
children
的Layout
在function
后支持function children
中Layout
{entity && <span>Name: {entity.name}</span>}
为什么我必须使用这些选项之一,我可以在渲染之前将React
它们children
视为函数并在内部解析块吗?
我试图了解低级和上级通配符的行为.
尝试编译以下代码时遇到问题.
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)
有人可以解释一下,这两个代码片段是如何工作的.如果有人可以提供其他示例/链接,那就太好了.
如果我上面做错了,请纠正我.
提前致谢.
自定义分页的任何示例?材料表和reactjs
。我想将页面大小传递给服务器,并且需要隐藏分页中的第一个和最后一个按钮
我需要有关已上传到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)运行后npm run dev
build 文件夹中没有 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) reactjs ×6
javascript ×2
children ×1
components ×1
css ×1
firebase ×1
generics ×1
html ×1
java ×1
jestjs ×1
maven ×1
mocking ×1
null ×1
pagination ×1
react-vis ×1
redux ×1
spring-boot ×1
typescript ×1