小编Leo*_*dov的帖子

React Native:为什么 stylesheet.create 返回带有数字而不是样式的对象?

我创建了样式,但有时我无法使用它们,因为它们返回数字:

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#FFFFFF'
    },
    moodSliderContainer: {
        justifyContent: 'center',
        alignItems: 'center',
        width: '100%'
    },
    postListContainer: {
        width: '100%',
        height: '100%',
        paddingBottom: 120
    }
});
console.log(styles);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

react-native

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

使用react-final-form时如何在输入字段上进行自动聚焦?

我使用创建了一个表单react-final-form。自动对焦无法正常工作。我知道的唯一解决方案是使用refReact的功能。我可以使用react-final-form库自动调整输入的焦点吗?

import React from "react";
import { render } from "react-dom";
import { Form, Field } from "react-final-form";

const App = () => (
  <Form
    render={({}) => (
      <form>
        <Field name="company" component="input" autofocus />
      </form>
    )}
  />
);

render(<App />, document.getElementById("root"));
Run Code Online (Sandbox Code Playgroud)

forms autofocus reactjs final-form react-final-form

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