小编wyn*_*007的帖子

React Native BottomTabNavigator 删除空白

我的底部选项卡导航器出现问题。我的选项卡和 iPhone 11 模拟器屏幕末端之间有一个空白区域。在 iPhone 8 模拟器上,我没有这些空白。选项卡上方还有一个小的空白区域。我怎样才能删除这个空间?我找不到解决方案,而且时间不多了。谢谢!在此处输入图片说明

在此处输入图片说明

到目前为止,这是我的实现:

详情导航.js

  const DetailsNavigation = ({ route }) => {
  return (
    <Tab.Navigator
      tabBarOptions={{
        activeBackgroundColor: colors.primary,
        activeTintColor: colors.secondary,
        inactiveBackgroundColor: colors.secondary,
        inactiveTintColor: colors.primary,
        labelStyle: {
          fontSize: 13,
          marginBottom: 5,
        },
      }}
    >
      <Tab.Screen
        name="DetailsScreen"
        options={{
          title: "Portfolio",
          tabBarIcon: ({ color, size }) => (
            <MaterialIcons name="account-box" size={24} color={color} />
          ),
        }}
        children={() => <DetailsScreen worker={route.params} />}
      />
      <Tab.Screen
        name="RatingScreen"
        component={RatingScreen}
        options={{
          title: "Bewertungen",
          tabBarIcon: ({ color, size }) => (
            <MaterialIcons name="star" size={24} color={color} …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-navigation

6
推荐指数
2
解决办法
1534
查看次数

React TypeScript:如何设置多个文件的状态?

我面临一个问题,可能是一个非常简单的问题,但我被困了几个小时,所以我想请求你的帮助。

我有一个简单的文件输入,我想将此文件设置为稍后在提交表单时上传文件。

const [inputTattoos, setInputTattoos] = useState<[{}]>();

const handleImageChange = async ({
    currentTarget: input,
  }: React.ChangeEvent<HTMLInputElement>) => {
    if (input.files === null) return;

    console.log(input.files);

    setInputTattoos([{ ...input.files }]);
Run Code Online (Sandbox Code Playgroud)

使用这段代码,我可以将文件写入状态,但这不是我想要将其存储在状态中的方式,因为我的状态如下所示:

在此输入图像描述

我有一个数组,里面有一个带有对象的对象。我实际上从 input.files 得到的只是一个包含对象的数组,但我无法像在控制台上获取它一样存储此 input.files 。我尝试了很多解决方案,但这是我发现唯一有效的方法。使用其他解决方案时,我总是在 State 中得到一个空对象或 FileList(未定义),例如使用以下解决方案:

const [inputTattoos, setInputTattoos] = useState<FileList>()
const handleImageChange = async ({
    currentTarget: input,
  }: React.ChangeEvent<HTMLInputElement>) => {
    if (input.files === null) return;

    console.log(input.files);

setInputTattoos(input.files);
Run Code Online (Sandbox Code Playgroud)

这是怎么回事?谢谢你!

typescript reactjs typescript-typings react-hooks

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