小编kei*_*eil的帖子

如何将引用附加到我使用 React.cloneElement 复制的组件

嘿,我想将引用传递到我的组件中,这样我就可以访问所述组件上的变量,例如状态。唯一的问题是我似乎无法让它工作。它需要能够同时适用于类和函数

我从 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)

javascript typescript reactjs react-native react-hooks

13
推荐指数
1
解决办法
2万
查看次数

如何使用react-native-testing-library getByRole

我正在尝试在 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

6
推荐指数
1
解决办法
3592
查看次数

event.js:174 throw er// 不允许未处理的“错误”事件操作

每次我尝试将我的应用程序部署到 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)

javascript android node.js reactjs react-native

6
推荐指数
1
解决办法
689
查看次数

使用 switchmap 和 forkjoin 链接可观察量无法按预期的角度打字稿 rxjs 工作

我目前正在尝试创建一个系统,如果我成功更新了请求,我会在 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 observable rxjs angularjs typescript

5
推荐指数
1
解决办法
2639
查看次数