小编hel*_*eer的帖子

React Native 中 ReactDOM 和 document.body 的等效变量是什么?(世博会)

我正在构建一个Modal用于 Web 上的 ReactJS 的组件。我小时候将其附加Modal到并根据需要安装/卸载。document.body

这是图表(Stephen Grider 的 Udemy 在线课程) 在此输入图像描述

我的问题是 React Native 中没有 ReactDOM 或 document.body。这是我的 modal.py

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { store } from '../store';
import { Provider } from 'react-redux';
class Modal extends Component {
  comoponentDidMount() {
    this.modalTarget = document.createElement('div');
    this.modalTarget.className = 'modal';
    document.body.appendChild(this.modalTarget);
    this._render();
  }

  _render() {
    ReactDOM.render(
      <Provider store={store}>
        <div>{this.props.children}</div>
      </Provider>,
      this.modalTarget
    );
  }

  componentWillUpdate() {
    this._render();
  }

  componentWillUnmount() {
    ReactDOM.unmountComponentAtNode(this.modalTarget); …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-navigation expo

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

如何绘制正方形以标记对象。(反应原生)

我看到许多移动应用程序都有一个功能,用户可以绘制一个正方形来指示要在图像上标记的内容。

我正在构建Face Tagging应用程序,基本上用户在图像上人脸的边界上绘制正方形

我在谷歌上搜索过很多次,但我不确定 RN 是否有一些用于标记的功能库。

我怎样才能做到这一点?有什么好的库可以在图像绘制正方形吗?如果我能记住它的坐标宽度、高度和矩形的位置就更好了。

任何想法或建议将不胜感激!

这是下面的一个例子

在此处输入图片说明

reactjs react-native react-animated react-image

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

如何显示图像的唯一部分

更新由于问题复杂且不清楚,因此我正在重写我的问题,以使其更加简单。

在此处输入图片说明

给定

  • 图片(整个图片的图片uri;示例中为600x600图片)
  • 左(x坐标;示例中为50)
  • 顶部(y坐标;示例中为100)
  • 宽度(图像的宽度;示例中为300)
  • 高度(图像的高度;示例中为300)

我想要的是

  • 300 x 300图像(裁剪到图像上)
  • 70 x 70图像(最终将图像尺寸调整为70 x 70尺寸)

这是我的示例代码

// render the part of the image
console.log(left); // 50
console.log(thumbSize); // 300
return (
        <Image
          source={{uri: image}}
          style={selectedStyle(left, top, thumbSize)}/>
      );
... 
function selectedStyle(left, top, thumbSize) {
  return {
    left,
    top,
    width: thumbSize,
    height: thumbSize
  };
}
Run Code Online (Sandbox Code Playgroud)

来自zvona的工作演示的更新,我想要的是这个。

在此处输入图片说明 但没有别的。

在此处输入图片说明

javascript css image reactjs react-native

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

"主要"功能位于何处?

' main'功能位于何处?

int main() {
    const char *str = "hello world";
    printf("%s\n", str);
}
Run Code Online (Sandbox Code Playgroud)

我知道这些地点:

  • .text
  • .data
  • .bss
  • stack
  • heap

我认为答案是.bss因为我知道' main功能不在其他人身上(但我可能错了).

c

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

如何在用户注销时重置TabNavigator(从其他屏幕)

这是我的项目文件层次结构

RootTabNavigator
    | AuthStackNavigator // I want to go back to this navigator
          | AuthoScreen
    | Welcome Screen
    | MainTabNavigator // I want to reset MainTabNavigator 
          | FeedStacknavigator
                   | Screen A
          | OtherStackNavigatorOne
                   | Screen E
          | OtherStackNavigatorTwo
                   | Screen D
          | MenuStackNavigator 
                   | Menuo <-I'm here and want to reset to 'MainTabNavigator' 
                             and go BACK to 'AuthScreen'
           | Screen B
                   | Screen C
Run Code Online (Sandbox Code Playgroud)

问题

用户在MenuStackNavigator和MainTabNavigator下的Menuo屏幕上.

如果用户没有令牌(当用户注销时),则用户返回到Auth Screen.

但同时我想重置MainTabNavigator.您可以卸载,执行NavigationActions.init()或其他任何操作.我更喜欢NavigationActions.init()

我只是想将MainTabNavigator设置为第一次.

如果没有令牌,我会回到Auth Screen(这是有效的)

This code if the part …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-redux react-native-navigation react-navigation

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

如何在反应导航中分派多个动作?

我想执行两个操作,但它不起作用。

const backAction = NavigationActions.back({
    key: null
})
const dispatchLogoutAction = NavigationActions.reset({
    index: 0,
    actions: [NavigationActions.navigate({routeName: "LoginView"})]
});
nextProps.navigation.dispatch(backAction);
nextProps.navigation.dispatch(dispatchLogoutAction);
Run Code Online (Sandbox Code Playgroud)

react-navigation除了并行列出 dispatch 语句之外,还有哪些其他方法可以调度这两个操作?

react-native redux-thunk react-navigation

5
推荐指数
0
解决办法
2564
查看次数

`x/24x $esp` 是什么意思?

我正在运行xv6- 由 MIT 制造的操作系统。我正在运行 gdb 来检查堆栈指针(?)。我正在运行gdb以查看堆栈指针寄存器的值。

我的教授说“让我们看看堆栈”然后输入x/24x $esp.

问题:什么是x, /, 24, $esp??? $esp 只是一个显示堆栈寄存器当前地址的堆栈指针?

我得到的输出是:

(gdb) x/24x $esp
0x7bdc: 0x00007db4  0x00000000  0x00000000  0x00000000
0x7bec: 0x00000000  0x00000000  0x00000000  0x00000000
0x7bfc: 0x00007c4d  0x8ec031fa  0x8ec08ed8  0xa864e4d0
0x7c0c: 0xb0fa7502  0xe464e6d1  0x7502a864  0xe6dfb0fa
0x7c1c: 0x16010f60  0x200f7c78  0xc88366c0  0xc0220f01
0x7c2c: 0x087c31ea  0x10b86600  0x8ed88e00  0x66d08ec0
Run Code Online (Sandbox Code Playgroud)

我从谷歌找到了一些参考:

x/6x $esp 以查看 int 放入堆栈中的内容。

(gdb) x/6x $esp
0x7bdc: 0x00007db4  0x00000000  0x00000000  0x00000000
0x7bec: 0x00000000  0x00000000
Run Code Online (Sandbox Code Playgroud)

这对我来说没有意义。

PS此时我需要找到堆栈的开头和堆栈上的项目。(一旦我理解了这个命令!)

参考: …

memory assembly stack operating-system xv6

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

Python3 中字典的空间复杂度

Python中这个字典的空间复杂度是多少?

(1)我的猜测:O(V+E),其中V是键的数量,E是字典中数组值的最大长度。

{
    'key' : ['value', 'value2', ...],
    'key2': ['value30', 'value31', ...],
    ...
}
Run Code Online (Sandbox Code Playgroud)

小问题:如果字典是由有向图构成的,那么它的空间复杂度应该是O(2E)吗?

(2)我的猜测:O(V),其中V是密钥的数量。

{
    'key' : 4,
    'key2': 5,
    ...
}
Run Code Online (Sandbox Code Playgroud)

python performance

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

(使用 SSH 运行命令时出错)命令行:第 0 行:配置选项错误

错误消息:

命令行:第 0 行:错误的配置选项:

sh '''ssh -i ${rundeck_rsa_key} -o StrictHostKeyChecking=no -o centos@xxxx.net "sudo su -c "sh ./home/centos/releases/xx.sh" rundeck"'''
Run Code Online (Sandbox Code Playgroud)

Broken Down 命令(我只是为了您的方便而制作了上述命令)

sh '''ssh -i ${rundeck_rsa_key} -o StrictHostKeyChecking=no 
      -o centos@xxxx.net "sudo su -c "sh ./home/centos/releases/xx.sh" servc"'''
Run Code Online (Sandbox Code Playgroud)

我试图

  1. ssh 进入服务器
  2. 将用户更改为“servc”
  3. 执行 xx.sh shell

我认为有一个语法错误"sudo su -c "sh ./home/centos/releases/xx.sh" servc"

你有什么线索吗?:D

bash jenkins

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

点击模式外部以关闭模式(react-native-modal)

有人有实施经验react-native-modal吗?当我使用它时,当我点击模态之外时,模态不会关闭。

这是我尝试过的

  • 添加 onBackdropPress(() => {this.props.hideModal()})
  • 在组件内部和外部添加 TouchableWithoutFeedback
  • 和许多其他方法...

这是我想要显示模式的屏幕。

render() {
    return (
        <View style={{flex: 1}}>
            <ScrollView>
               // CONTENT HERE
               {this._renderModal()} //rendering modal here
               <FABs onFABsPress={this._showModal} /> // I open Modal when I press the FABs button
            </ScrollView>
        </View>
    )
);

_renderModal = () => {
    return (
      <CameraImageSelectModal
        hideModal={this._hideModal}
        isModalVisible={this.state.isModalVisible}
        navigation={this.props.navigation}
      />
    )
}
Run Code Online (Sandbox Code Playgroud)

这是模态组件:CameraImageSelectModal.js

render() {
    let { isModalVisible } = this.props;
    return (
      <View>
        <Modal
          isVisible={isModalVisible}
          onBackdropPress={() => {console.log('hey')}}>
          transparent={true}>
          <View style={styles.modalContainer}>
            <View style={styles.modalTitleTextContainer}> …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-modal

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