小编san*_*eni的帖子

我正在尝试使用 npm 安装新组件。但它给出了错误

我试图添加,$ npm install react-native-touchable-bounce --save但它给出了与以下相同的错误。然后我删除了所有node_modules仍然出现此错误。 npm install给出以下错误。

PS I:\Code\singal res\code\singalRes> npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined      
npm ERR! Found: react-native-svg@12.1.0
npm ERR! node_modules/react-native-svg
npm ERR!   react-native-svg@"^12.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native-svg@"^9.13.6" from @ui-kitten/components@5.0.0
npm ERR! node_modules/@ui-kitten/components
npm ERR!   @ui-kitten/components@"^5.0.0" from the root project
npm ERR!
npm ERR! Fix the …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native npm-install

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

错误:无法对卸载的组件执行 React 状态更新

这是完全错误

警告:无法对卸载的组件执行 React 状态更新。这是一个空操作,但它表明您的应用程序中存在内存泄漏。要修复,请取消 useEffect 清理函数中的所有订阅和异步任务。在注册页面

这是我的 siguppage.js 文件

import React, { useState } from 'react'
import { withFirebase } from '../firebase/Context'
import { useHistory } from 'react-router-dom'
import { compose } from 'recompose'
import withAuthUser from '../UserData/withAuthUser'

const SignUpPage = (props) => {
    const [Email, setEmail] = useState('')
    const [PasswordOne, setPasswordOne] = useState('')
    const [PasswordTwo, setPasswordTwo] = useState('')
    const [UserName, setUserName] = useState('')
    const [error, setError] = useState('')
    let history = useHistory()
    const [AuthUser, setAuthUser] = props.AuthUser()

    const onSubmit …
Run Code Online (Sandbox Code Playgroud)

reactjs

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

如何将图像数据响应转换为 Image base64?

这是我的 api

https://besticon-demo.herokuapp.com/icon?url=facebook.com&size=80..120..200

当我在邮递员中测试这个时,我得到了 Image..但是我怎么能用axios. 我现在用 Axios 得到了很长的字符串(比如?PNG...)

那么我如何使用该响应来显示图像..

   axios.get(RequestURL, { withCredentials: false })
                .then(function (response) {
                    // handle success
                    console.log(response)
                    var b64Response = btoa(response.data) 
                    setImageServer('data:image/png;base64,' + b64Response) // not showing image
                })
Run Code Online (Sandbox Code Playgroud)

尝试运行时也会出错 btoa

DOMException:无法在“Window”上执行“btoa”:要编码的字符串包含超出 Latin1 范围的字符。

HTML

 <img src={ImageServer}/>
Run Code Online (Sandbox Code Playgroud)

javascript reactjs axios

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

如何在 TypeScript 文件中接收任何元素作为 ReactChild?

我正在使用一个库,其中包含<Carousel>我试图向其中添加一些子元素的元素,如下所示。

                               <Carousel>
                                    <div>
                                        <img
                                            style={{ width: 350, height: 197, borderRadius: 10 }}
                                            src={
                                                'https://resize.indiatvnews.com/en/resize/newbucket/1200_-/2020/05/salon-lockdown-1590854316.jpg'
                                            }
                                        ></img>
                                    </div>
                                </Carousel>
Run Code Online (Sandbox Code Playgroud)

但这给了我一个错误

类型“Element”不可分配给类型“(ReactChild[] & (boolean | ReactChild | ReactFragment | ReactPortal | null)) | 不明确的'。类型“ReactElement<any,any>”不可分配给类型“ReactChild[] & ReactPortal”。类型“ReactElement<any,any>”缺少类型“ReactChild[]”中的以下属性:length、pop、push、concat 等 28 个属性。TS2322

      144 |                             >
      145 |                                 <Carousel>
      146 |                                     <div>
          |                                     ^
      147 |                                         <img
      148 |                                             style={{ width: 350, height: 197, borderRadius: 10 }}
>     149 |                                             src={
Run Code Online (Sandbox Code Playgroud)

如何禁用该元素的 TypeScript 检查?

typescript reactjs

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

错误:- 解包的值太多(预期为 2)python 函数

我的代码:-

Videos10k=[{'title': '', 'titleWords': ['...','...'], 'titleLength': 10, 'likes': 86, 'disLikes': 5, 'views': 2202, 'creator': '...', 'description': '...'}]
def getavg(number, array=[]):
    views_avg = 0
    for idx, Video in array:
        views = Video["views"]
        views_avg = views_avg + views

    views_avg = views_avg / len(array)
    print("Average views for " + number + " " + views_avg)


getavg("10k", Videos10k)
Run Code Online (Sandbox Code Playgroud)

我收到此错误。错误:-

在 idx 的 getavg 中,数组中的视频:ValueError:要解压的值太多(预期为 2)

python

0
推荐指数
2
解决办法
56
查看次数