小编Gab*_*el 的帖子

React Native 导航标题标题太长,最终溢出

我一直在关注 React Native 的教程,但我的输出与视频的输出有所不同。

您基本上从上一个屏幕获取标题参数,然后将其显示在标题标题上,如果太长,他的标题就会被截断,但我的只是重叠所有内容,我考虑只是手动截断字符串,但长度在不同的情况下会有所不同屏幕,所以我想知道是否有人可以指出我正确的方向,我将非常感激。

这是该组件的代码:

const MealDetailScreen = props => {
  const mealId = props.navigation.getParam("mealId");
  const meal = MEALS.find(meal => meal.id === mealId);

  return (
    <View style={styles.screen}>
      <Text>This is the {meal.title}!</Text>
      <Button title="Back" onPress={() => props.navigation.goBack()} />
    </View>
  );
};

MealDetailScreen.navigationOptions = navigationData => {
  const mealId = navigationData.navigation.getParam("mealId");
  const meal = MEALS.find(meal => meal.id === mealId);

  return {
        headerTitle: meal.title,
  };
};
Run Code Online (Sandbox Code Playgroud)

,这是输出:输出

react-native

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

Next js with Prisma:基于两个条件的更新插入

我正在尝试使用 Prisma 执行以下操作:

如果存在具有相同哈希和 user_id 的类别行,只需更新它的“名称”字段,否则,创建该行

这可能吗?TS 给我一个错误,说“where”上给出的密钥类型必须是 of categoriesWhereUniqueInput,但是 hash 和 user_id 都不是唯一的,它们可以重复,这是两者之间的组合将是唯一的

我该如何解决这个问题?我是否必须手动检查是否有 id 并根据该 id 进行更新/创建?

预先非常感谢!

  const category = await prisma.categories.upsert({
    where: {
      hash,
      user_id: id,
    },
    update: {
      name,
    },
    create: {
      hash,
      name,
      user_id: id,
    },
  });
Run Code Online (Sandbox Code Playgroud)

postgresql reactjs next.js prisma

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

Firebase with Node,“面向浏览器的 Firebase 包”

我得到了 Node 的 npm“firebase”包,创建了一个 firebaseConfig.js 文件,然后添加了这个:

const firebase = require("firebase/app");
console.log(firebase);

const firebaseConfig = {
 ...
};

firebase.initializeApp(firebaseConfig);
Run Code Online (Sandbox Code Playgroud)

起初,我收到一个错误说“initializeApp is not a function”,我真的没有得到,看到内容后firebase,我将最后一行更改为

firebase.default.initializeApp(firebaseConfig);

哪个有效,但现在我在控制台上收到此警告;

      Warning: This is a browser-targeted Firebase bundle but it appears it is being
      run in a Node environment.  If running in a Node environment, make sure you
      are using the bundle specified by the "main" field in package.json.
Run Code Online (Sandbox Code Playgroud)

我真的不明白我应该在这里做什么,我真的可以使用一些指导,所以提前非常感谢!

node.js express firebase firebase-storage

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