小编Dan*_*ona的帖子

错误:找不到符号导入com.facebook.react.bridge.ColorPropConverter

每次我尝试使用运行我的 React Native 项目时react-native run-android,它都会抛出以下错误

\RenderableView.java:30: error: cannot find symbol
import com.facebook.react.bridge.ColorPropConverter;
\Documents\GitHubProjects\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\RenderableView.java:30: error: cannot find symbol
import com.facebook.react.bridge.ColorPropConverter;
                                ^
  symbol:   class ColorPropConverter
  location: package com.facebook.react.bridge
\Documents\GitHubProjects\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\SvgView.java:26: error: cannot find symbol
import com.facebook.react.bridge.ColorPropConverter;
                                ^
  symbol:   class ColorPropConverter
  location: package com.facebook.react.bridge
\Documents\GitHubProjects\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\RenderableView.java:480: error: cannot find symbol
                      color = ColorPropConverter.getColor(colors.getMap(1), getContext());
                              ^
  symbol:   variable ColorPropConverter
  location: class RenderableView
\Documents\GitHubProjects\node_modules\react-native-svg\android\src\main\java\com\horcrux\svg\SvgView.java:180: error: cannot find symbol
          mTintColor = ColorPropConverter.getColor(tintColor.asMap(), getContext());
                       ^
  symbol:   variable ColorPropConverter
  location: class SvgView
4 errors
Run Code Online (Sandbox Code Playgroud)

请记住,这是我从 GitHub 克隆存储库并运行npm …

android reactjs react-native

10
推荐指数
1
解决办法
9798
查看次数

“EventTarget”类型的参数不可分配给“HTMLFormElement”类型的参数

在我的屏幕上,我试图定义一个函数来处理表单的提交,但是,我遇到了打字稿错误的问题:

Argument of type 'EventTarget' is not assignable to parameter of type 'HTMLFormElement'

我的代码如下所示:

import React, { FormEvent } from 'react';
import Form from 'react-bootstrap/Form';
import LoadingButton from '../shared/LoadingButton';
import { useSignIn } from '../../hooks/Auth/useSignIn';
import { useHistory } from 'react-router-dom';
import ErrorIndicator from '../shared/ErrorIndicator';

function SignIn() {
    const { mutateAsync, error, isError, isLoading } = useSignIn();
    const history = useHistory();

    const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
        event.preventDefault();
        const data = new FormData(event.target); // Error appears here
        const …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

7
推荐指数
1
解决办法
2490
查看次数

将参数传递给 Firebase Cloud Functions

我正在尝试编写一个 Firebase Cloud 函数来向用户显示推送通知。首先,我在 Firestore 数据库中创建通知,然后调用 Firebase 云函数向用户发送推送通知。问题是我真的不知道如何将参数传递给云函数

我这样调用该函数:

import { sendNotificationToUser, sendNotificationToNonUser } from '../../api/PushNotification';

export function createNotification(values, callback) {
  return async dispatch => {
    try {
      ...
      const newNotificationRef = firestore().collection('notifications').doc(notId);

      const newNotification = await firestore().runTransaction(async transaction => {
        const snapshot = await transaction.get(newNotificationRef);
        const data = snapshot.data();

        return transaction.set(newNotificationRef, {
          ...data,
          ...values,
          id: notId,
          viewed: false
        });
      });

      if (newNotification) {
        if (values.reciever === null) {
          sendNotificationToNonUser(values.title, values.message);
          ...
        } else {
          sendNotificationToUser(values.title, values.message, values.reciever);
          ...
        } …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native google-cloud-functions

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

UnicodeDecodeError:cp932编解码器无法解码位置81的字节0x81

我正在尝试使用2个python脚本打开'.obj'文件,但是当我尝试编译项目时,它会抛出下一条错误消息:

UnicodeDecodeError: cp932' codec can't decode byte 0x81 in position 81: illegal multibyte sequence 
Run Code Online (Sandbox Code Playgroud)

我的代码看起来像这样:

CarString = 'volks.obj'
global car
global objects

obj = test3.object()    
car = obj.load_obj(CarString)

objects.append(glGenLists(1))
Run Code Online (Sandbox Code Playgroud)

类对象:

class object():
    def __init__(self, obj = None):
        if obj:
            self.load_obj(obj)
            #self.displaylist = self.crear_dl()

    def load_obj(self, file):
        with open(file, 'r') as obj:
            data = obj.read() 
Run Code Online (Sandbox Code Playgroud)

data = obj.read()
Run Code Online (Sandbox Code Playgroud)

部分是什么引发了我这个错误.我是Python的新手,所以我可以使用一些帮助来解决这个问题.谢谢.

python unicode python-3.x

3
推荐指数
1
解决办法
3342
查看次数

错误:MainActivity.java 上需要类、接口或枚举

我正在尝试编译一个在 Android Studio 上使用 Expo 的应用程序,但是,每次尝试时都会收到以下错误消息:

\android\app\src\main\java\com\profileid\MainActivity.java:2: error: class, interface, or enum expected
package com.projectname;
Run Code Online (Sandbox Code Playgroud)

我刚刚升级到 Expo SDK 43 并从react-native-unimodules.

我的 MainActivity.java 如下所示:

import expo.modules.ReactActivityDelegateWrapper;
package com.projectname;

import android.os.Bundle;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

import expo.modules.splashscreen.singletons.SplashScreen;
import expo.modules.splashscreen.SplashScreenImageResizeMode;

public class MainActivity extends ReactActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // SplashScreen.show(...) has to be called after super.onCreate(...)
    // Below line is handled by '@expo/configure-splash-screen' command and it's discouraged to modify it manually
    SplashScreen.show(this, …
Run Code Online (Sandbox Code Playgroud)

java android android-studio reactjs

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

Typescript:运算符“+”不能应用于类型“number”和“boolean”

我有一个代表数字的字符串数组,我希望能够查看某个字符串在我的数组中重复了多少次:

const numbers = ['1', '2', '3', '4', '6', '2', '9', '5', '2'. '4', '8'];
const searchForValue = '2';
const timesAppeared = numbers.reduce(
      (previousValue, currentValue) => previousValue + (currentValue === searchForValue),
      0
);
Run Code Online (Sandbox Code Playgroud)

然而,我的reduce函数内部的操作给出了以下错误:

Operator '+' cannot be applied to types 'number' and 'boolean'.

我该如何解决这个问题?

javascript typescript

0
推荐指数
1
解决办法
234
查看次数