嘿,我想将引用传递到我的组件中,这样我就可以访问所述组件上的变量,例如状态。唯一的问题是我似乎无法让它工作。它需要能够同时适用于类和函数
我从 console.log 收到的每次都是 null
const testRef = createRef();
console.log(testRef)
const elementToCopy = singleScreenState.screen.peek().element;
const Element = React.cloneElement(elementToCopy as ReactElement, { ...elementToCopy?.props, forwardRef: testRef })Run Code Online (Sandbox Code Playgroud)
我正在尝试在 React Native 测试库中使用getByRole,但我一生都无法弄清楚语法
有问题的组件 -
<Text
accessibilityRole={'button'}
accessibilityLabel={'upvote count'}
style={[styles.upvoteText, styles.upvoteCount]}>
{upvoteCount}
</Text>
Run Code Online (Sandbox Code Playgroud)
和我的代码
expect(getByRole('button', {name: 'upvote count'} as MatcherOptions)).toBe(2)
Run Code Online (Sandbox Code Playgroud) typescript reactjs jestjs react-native react-testing-library
每次我尝试将我的应用程序部署到 android 时我都会得到这个,它破坏了我的 Metro 服务器。
我尝试更新我的环境变量。
events.js:174
throw er; // Unhandled 'error' event
^
Error: EPERM: operation not permitted, lstat 'C:\Users\user\Documents\DEV\react-native-dualscreen\dualscreeninfo\examples\android\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\androidx\lifecycle\viewmodel'
Emitted 'error' event at:
at NodeWatcher.<anonymous> (C:\Users\user\Documents\DEV\react-native-dualscreen\dualscreeninfo\examples\node_modules\sane\src\node_watcher.js:291:16)
at FSReqWrap.oncomplete (fs.js:153:21)
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试创建一个系统,如果我成功更新了请求,我会在 forkjoin 中触发 3 个可观察量,然后一旦这些完成,console.log('complete/or finish') 否则,如果没有,则不执行任何操作。目前,虽然可观察量在分叉连接完成之前就已完成,但我完全不知道发生了什么,
copyAttachments(): Observable<any> {
if (this.model.attachments.length > 0) {
return this.attachmentService.copyAttachments(this.model.attachments, this.model.id);
}
return empty();
}
uploadAttachments(): Observable<any> {
this.showAttachmentsUploadingModal = true;
const formData = new FormData();
if (this.formAttachments.length > 0) {
this.showAttachmentsUploadingModal = true;
this.formAttachments.forEach(file => {
formData.append('files', file, file.name);
});
}
// uploading empty formData will still trigger creation of default folder structure
return this.attachmentService.uploadAttachments(formData, this.model.id);
}
uploadCustomerData(): Observable<any> {
this.showAttachmentsUploadingModal = true;
const formData = new FormData();
if (this.formCustomerData.length > 0) …Run Code Online (Sandbox Code Playgroud)javascript ×3
react-native ×3
reactjs ×3
typescript ×3
android ×1
angularjs ×1
jestjs ×1
node.js ×1
observable ×1
react-hooks ×1
rxjs ×1