我正在尝试在 Android 模拟器 (Genymotion) 上使用 Expo 设置 Detox 但我遇到了一个无法解决的错误....
我已经安装了必要的软件包:
在官方展会网站上下载了 Exponent.apk
设置我的 package.json :
"detox": {
"test-runner": "jest",
"configurations": {
"android": {
"binaryPath": "bin/Exponent.apk",
"build": "npm run android",
"type": "android.attached",
"device": {
"adbName": "192.168.58.101:5555"
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在 e2e 文件夹上设置 config.json :
{
"setupFilesAfterEnv": ["./init.ts"],
"testEnvironment": "node",
"reporters": ["detox/runners/jest/streamlineReporter"],
"verbose": true
}
Run Code Online (Sandbox Code Playgroud)
设置我的 init.ts 文件:
import {cleanup, init} from "detox";
import * as adapter from "detox/runners/jest/adapter";
const config = require("../package.json").detox;
jest.setTimeout(120000);
jasmine.getEnv().addReporter(adapter);
beforeAll(async () => …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 React-native 和 Expo 在 Android 上实现生物识别身份验证(faceID/指纹)。
使用该LocalAuthentication.authenticateAsync()功能,用户能够使用他的生物特征进行身份验证。但如果失败,用户必须再次按下生物识别认证。
所以我尝试了一个 recursif 或 do while 循环的小技巧,但结果很奇怪:
const scanFingerPrint = async () => {
try {
const results = await DeviceService.biometricAuthentication();
if (results.success) {
SecureStoreService.getCredential()
.then(credentials => onScan(credentials));
} else {
ShakeAnimation(animatedValueModal);
return scanFingerPrint();
}
} catch (e) {
console.log(e);
}
};
Run Code Online (Sandbox Code Playgroud)
使用此代码,如果用户未通过生物识别身份验证,它将无限地传入“else”...
所以我想知道如何在android上处理它。
我正在尝试在平面列表中实现类似“onBeginReached”的道具。我想以对用户透明的方式在数据数组的开头附加一些数据。
所以使用这个 flatList :
const App = () => {
const flatListRef = useRef(null);
const [data, setData] = useState(generateData(20));
const renderItem = ({ item }) => {
console.log(item);
return (
<View style={styles.itemContainer}>
<Text style={styles.itemText}>{item}</Text>
</View>
);
};
const handleMomentumScroll = (event) => {
console.log("Momentum end")
const xOffset = event.nativeEvent.contentOffset.x;
const index = Math.round(xOffset / 30);
if (index < 1) {
setData([-10 ,-9, -8, -7, -6,-5, -3, -2, -1, ...data]);
}
};
return (
<FlatList
style={{ width: 200, alignSelf: 'center', marginTop: …Run Code Online (Sandbox Code Playgroud) 我想在约会上添加一些日子,但实际上我得到了一个奇怪的结果......
我今天测试当天(28/02/2019),尝试添加400天,我在2096年...我认为tere是一个问题
看看我的功能:
const user = { LastReport: new Date(), Validite: "413" }
var temp = new Date(user.LastReport)
console.log("Current : " + temp);
user.DateValide = temp.setDate(temp.getDate() + user.Validite);
console.log("Day to add : " + user.Validite)
console.log("Result : " + new Date(user.DateValide))Run Code Online (Sandbox Code Playgroud)
和我的结果:
有什么我做错了吗?
我正在尝试在定义的位置添加一个角色.我已经创建了一个新函数,为一个char分配一个内存,在该位置之后保存字符,然后在定义的位置添加我的字符,现在我不知道如何在该位置之后擦除字符以连接保存的字符串.有解决方案吗
这是我的功能的开始:
void appendCharact(char *source, char carac, int position) {
source = realloc(source, strlen(source) * sizeof(char) + 1); //Get enough memory
char *temp = source.substr(position); //Save characters after my position
source[position] = carac; //Add the character
}
Run Code Online (Sandbox Code Playgroud)
编辑:我正在尝试实现另一个"野蛮"的解决方案,在调试模式下,我可以看到我差不多是我的新字符串,但看起来我无法删除旧指针...
void appendCharact(char *source, char carac, int position) {
char *temp = (char *)malloc((strlen(source) + 2) * sizeof(char));
int i;
for(i = 0; i < position; i++) {
temp[i] = source[i];
}
temp[position] = carac;
for (i = position; i < strlen(source); i++) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用引用从其父级访问子组件函数。
我有我的父组件:
const Parent: FC = (props) => {
let childRef = useRef(null);
const handle = () => {
childRef.current.customFunction();
}
return (
<Children props1="value" ref={childRef}/>
<Button onPress={handle}/>
}
Run Code Online (Sandbox Code Playgroud)
我的孩子们的组成部分:
interface Props {
props1: string
}
const Children: FC<Props> = forwardRef((props,ref) => {
const customFunction = () => {
console.log("Custom");
}
return <View>props.children</View>
})
Run Code Online (Sandbox Code Playgroud)
渲染我的子组件时出现打字稿错误:
类型“intrinsicAttribute & props & {children?:ReactNode}”上不存在属性“ref”
请注意,我想保留任何严格类型。
react-native ×4
expo ×2
android ×1
biometrics ×1
c ×1
date ×1
detox ×1
fingerprint ×1
javascript ×1
string ×1
typescript ×1