我的 React Native 项目有问题。
新创建的项目npx react-native init ProjectName,安装pods并iOS尝试运行该项目,它会抛出下一个错误:无法在 Xcode 中找到“NativeVibrationSpec”的协议声明。
节点版本:14.18.1
Xcode 版本:13.0 (13A233)
运行模拟器:配备 iOS 15.0 的 iPhone 13
有决心吗?
我有一个 React Native 应用程序,其中有一些文件,其中包含一些调用某些端点的方法。当我尝试运行时,Jest导入的本地文件抛出错误。

我有下一个package.json:
{
"name": "appName",
"version": "1.0.0",
"description": "some description",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.14.2",
"@react-native-community/async-storage": "^1.12.1",
"@react-native-community/netinfo": "^6.0.0",
"isomorphic-fetch": "^3.0.0",
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3"
},
"jest": {
"automock": false,
"setupFiles": [
"./jest.setup.js"
]
}
}
Run Code Online (Sandbox Code Playgroud)
文件jest.setup.js如下:
import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js'
jest.mock('@react-native-community/netinfo', () => mockRNCNetInfo)
Run Code Online (Sandbox Code Playgroud)
目前,该内容已被注释,否则会抛出如图所示的相同错误。
我尝试在另一个项目中测试相同的内容,该@react-native-community/netinfo包未保存在devDependencies其中,但dependencies它有效,但我不确定这是否是问题所在。在这个特定的项目中,我不能让它package作为dependency,它应该在devDependencies. …
我有一个我想bulk insert进入mysql的方法。我正在使用NodeJS和mysql2。
我的方法:
\ncreateWorklog = async ({ sqlArray }) => {\n const sql = `INSERT INTO ${this.tableName}\n (project_id, user_id, date, duration, task, description) VALUES ?`\n\n const result = await query(sql, [sqlArray])\n const affectedRows = result ? result.affectedRows : 0;\n\n return affectedRows;\n}\nRun Code Online (Sandbox Code Playgroud)\n其中sqlArray是 an array of arrays,其中所有子数组的长度都相同。
query该方法中调用的方法是下一个:
query = async (sql, values) => {\n return new Promise((resolve, reject) => {\n const callback = (error, result) …Run Code Online (Sandbox Code Playgroud) 我有一个自定义组件,RefreshControl这样我就可以更改title propertyRefreshControl 提供的内容。
最后这是我的自定义RefreshControl组件的返回:
const [counter, setCounter] = useState(0)
useEffect(() => {
if (!refreshing && counter > 0) {
setTimeout(() => {
setCounter(previousValue => previousValue + 1)
}, 500)
}
!refreshing && counter === 0 && setCounter(previousValue => previousValue + 1)
}, [refreshing])
return (
<RefreshControl
onRefresh={onRefresh}
refreshing={refreshing}
title={counter > 1 ? 'Refreshing': 'Loading data'}
tintColor={Colors.main}
titleColor={Colors.main}
/>
)
Run Code Online (Sandbox Code Playgroud)
我的这个组件的用途如下FlatList:
<FlatList
ref={flatListRef}
style={styles.flatList}
contentContainerStyle={styles.contentContainer}
showsVerticalScrollIndicator={false}
data={data}
renderItem={renderItem}
keyExtractor={item => item.number.toString()}
refreshControl={
<MyRefreshControl …Run Code Online (Sandbox Code Playgroud) 我有两个表:Score table和Teams table。它们都包含其他表中的一些外键,但就我而言,我不需要其他表中的列。
我想得到team id and points一个SELECT query. 这些点是从 a 中得出的COUNT of MAX score of a team per round。
Score table:
| ID | 回合编号 | 团队 ID | 分数 |
|---|---|---|---|
| 1085e36b-7621-4634-93e2-c5404108ed23 | 424d4186-4432-4b8d-ab9d-00ee71945cf6 | 752f9ebc-7016-42f2-be90-768711fc3d46 | 18 |
| 47ff3765-6357-47bc-abb8-6b5adf436546 | 424d4186-4432-4b8d-ab9d-00ee71945cf6 | 90dd8de4-8ddc-46cd-8b67-d93edbede174 | 7 |
| b26b1a5b-8606-4c08-b838-30fdbcf98697 | 3fbb49a0-7a8a-4db5-b854-84a9ce7ac2b3 | 90dd8de4-8ddc-46cd-8b67-d93edbede174 | 20 |
| c1add78a-94a3-48cf-b89d-4e4500ab738d | 3fbb49a0-7a8a-4db5-b854-84a9ce7ac2b3 | 752f9ebc-7016-42f2-be90-768711fc3d46 | 21 |
Teams table:
| ID | 姓名 | 比赛ID |
|---|---|---|
| 2b56a499-9fc4-40c2-a7c4-43762c2b27e7 | 2@1.com 和 4@1.com | 9aaa6f86-5555-49b8-99a6-900a90dc3c7c |
| 752f9ebc-7016-42f2-be90-768711fc3d46 | 5@1.com 和 3@1.com | 9aaa6f86-5555-49b8-99a6-900a90dc3c7c |
| 7c9aa32a-ff99-4169-9512-27bc0aac0093 | 7@1.com 和 6@1.com | 9aaa6f86-5555-49b8-99a6-900a90dc3c7c |
| 90dd8de4-8ddc-46cd-8b67-d93edbede174 | 8@1.com 和 1@1.com | 9aaa6f86-5555-49b8-99a6-900a90dc3c7c |
正如您所看到的 …
react-native ×3
mysql ×2
android ×1
babeljs ×1
bulkinsert ×1
ios ×1
javascript ×1
jestjs ×1
node-mysql2 ×1
node.js ×1
reactjs ×1
sql ×1
subquery ×1