我花了一整天的时间深入研究 Enzyme 文档并开始掌握基础知识。
我在我的 Redux 存储中循环访问一些数据以将这些嵌套<BudgetWidgetCard />
组件呈现到我的父组件中,并希望确保X
它们中的一部分被呈现到页面上。
<div>
<main className="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
<h1 name='main-header-title'>{metaProperties.pageTitle}</h1>
{budgetWidgets.map((widget, i) => {
return <BudgetWidgetCard className='budget-widget' title={widget} key={i} state={this.props} />
})}
</main>
</div>
Run Code Online (Sandbox Code Playgroud)
it('+++renders the budget widget items correctly', () => {
console.log(wrapper.children().children().filter('budget-widget').length)
console.log(wrapper.find(<BudgetWidgetCard />).forEach(child => {
console.log(child.text())
}))
})
Run Code Online (Sandbox Code Playgroud)
我不喜欢调用 children().children()... 的想法似乎紧密耦合,但也许这就是要走的方法。我的最终目标是要简单地状态浅呈现的componentA
具有X
数<BudgetWidgetCards />
我得到以下输出:
Review Current Budget<BudgetWidgetCard /><BudgetWidgetCard /><BudgetWidgetCard /><BudgetWidgetCard />Add A New Budget Item<ReduxForm /><BudgetTable />
Run Code Online (Sandbox Code Playgroud)
使用以下内容时:
wrapper.children().forEach(child=> {
console.log(child.text()) …
Run Code Online (Sandbox Code Playgroud) 我的查询中不断收到以下错误graphql
,但不确定原因:
POST body missing. Did you forget use body-parser middleware?
我在这里做了什么奇怪的事情吗?我已经尝试了在线 body-parser 的不同建议,但似乎仍然无法修复它。
require('babel-polyfill')
const express = require('express')
const router = require('./middleware')
const expressStaticGzip = require('express-static-gzip')
const app = express()
const port = process.env.EXPRESS_PORT || 4000
const bodyParser = require('body-parser')
app.use(/\/((?!graphql).)*/, bodyParser.urlencoded({ extended: true }))
app.use(/\/((?!graphql).)*/, bodyParser.json())
app.use('/search/data', expressStaticGzip('public'))
app.use('/', router)
app.listen(port, () => {
console.log(`Server is running on port ${port}`)
})
Run Code Online (Sandbox Code Playgroud)
const router = express.Router()
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将 perf_hooks 用于 node.js 中的performance
API。
const { performance } = require('perf_hooks')
但是,我不断得到Module not found: Error: Can't resolve 'perf_hooks
. 我跑过去node -v
看看10.15
我有一个包裹com.test.mythingimport
.理想情况下,我想要调用它com.test.mything.import
.你能用它来命名import
或者会引起冲突吗?
我为我的VPC保留了以下CIDR - > 10.0.0.0/22
这告诉我的是,我的主机ips或1,024
地址有10位剩余.我试图计算有效地址的范围,因为亚马逊在创建新的私有子网时要求有效的IPv4 CIDR块.
我想从第3个八位字节中取出6/8位,最后一个八位字节全部为0,这导致我的IP范围为10.0.0.0 -> 10.0.3.255
.
当我到屏幕上实际选择我的IPv4 CIDR块时,我得到一个"无效错误",这只是验证我不理解数学实际上是如何工作的.我输入了10.0.2.1/28
一个必须是有效的Ipv4 CIDR错误.
这看起来像是在我计算的范围内,我希望我的私有子网保留16个IP地址.
我究竟做错了什么?
我在 Intellij 中使用 google checkstyle:https : //github.com/google/styleguide
当我在 IntelliJ 中进行任何编码期间进行格式化时,我运行了这个 eclipse checkstyle,它似乎工作正常。我想要一个 Maven 阶段,每当我运行mvn clean install
.
我正在使用以下插件:
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>format</goal>
</goals>
<configuration>
<configFile>src/main/resources/eclipse-java-google-style.xml</configFile>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
不幸的是,它似乎没有正确注册该配置文件。我想知道获取正确的 checkstyle 配置的最佳经验法则是什么。我把它放在哪里以及如何在我的 POM 中表示它?
this.validate_label_population();
this.validate_title_prefix();
this.validate_title_suffix();
this.executeGitCommentCreation();
Run Code Online (Sandbox Code Playgroud)
我在构造函数中执行以下函数.前3/4是异步函数:
例:
async validate_title_prefix() {
console.log('validate_title_prefix not implemented');
}
Run Code Online (Sandbox Code Playgroud)
我想this.executeGitCommentCreation();
在之前运行之后执行最后一次.做这个的最好方式是什么?我应该在前3名前面等待,还是使用某种Promise.all?
如果可以简化Or表达式Java,我一直很好奇.例:
int mapVal = occurrenceMap.get(node.nextNode.nodeVal);
if (mapVal != null || mapVal != 5 )
Run Code Online (Sandbox Code Playgroud)
与...
if (occurrenceMap.get(node.nextNode.nodeVal) != ( null || 1) )
Run Code Online (Sandbox Code Playgroud)
IMO,第二个更具可读性,但想知道语言是否支持这样的东西.
我有一个基本的HTML表格,可以呈现Redux的一些输入数据。我想测试一下,对象1在<tr></tr>
1中正确渲染,对象2在<tr></tr>
2中正确渲染,依此类推。
import React, { PropTypes } from 'react';
let getBudgetItems = (budgets) => {
return budgets.map((budget, key) => {
return (
<tr className = "add-budget-table-row" key={"budget_item_" + key}>
<td>{budget.budgetCategory}</td>
<td>${budget.budgetCost}</td>
<td>{budget.budgetDate}</td>
<td><button className="btn btn-primary">Edit Budget</button></td>
</tr>
);
});
};
const RenderBudgetTable = ({ budgets }) => {
return (
<div className="table-responsive">
<table className="table table-hover add-budget-table">
<thead>
<tr>
<th>Budget Name</th>
<th>Monthly Cost</th>
<th>Due Date</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{getBudgetItems(budgets)}
</tbody>
</table>
</div>
);
};
RenderBudgetTable.propTypes …
Run Code Online (Sandbox Code Playgroud) java ×3
reactjs ×3
enzyme ×2
node.js ×2
checkstyle ×1
es6-promise ×1
express ×1
graphql ×1
ip ×1
javascript ×1
jestjs ×1
maven ×1
networking ×1
promise ×1
react-redux ×1
redux ×1
subnet ×1
vpc ×1