GVKun编程网logo

react使用ant design RangePicker 报错invalid hook call(react.createelement type is invalid)

4

最近很多小伙伴都在问react使用antdesignRangePicker报错invalidhookcall和react.createelementtypeisinvalid这两个问题,那么本篇文章就

最近很多小伙伴都在问react使用ant design RangePicker 报错invalid hook callreact.createelement type is invalid这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展"Invariant Violation: Invalid hook call. Hooks can only~~" 引入react-native-safe-area-context时报错、An invalid character [32] was present in the Cookie value 错误、android – 如何使用“CookieManager :: removeAllCookies(ValueCallback callback)”、angular-cli6使用ng serve --o 控制台报错Invalid Host Header等相关知识,下面开始了哦!

本文目录一览:

react使用ant design RangePicker 报错invalid hook call(react.createelement type is invalid)

react使用ant design RangePicker 报错invalid hook call(react.createelement type is invalid)

在使用 RangePicker 前正常,引入RangePicker 后报如下错误:

 

 

但是我项目中并没有使用hook,按照提示的可能原因,猜想是版本不兼容问题,看了一下antd版本为4.5.4,eact版本为16.13.1。

于是重新安装4.5.3版本的antd,安装好重启,日历可以正常使用。

总结

以上是小编为你收集整理的react使用ant design RangePicker 报错invalid hook call全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

"Invariant Violation: Invalid hook call. Hooks can only~~" 引入react-native-safe-area-context时报错

您不能在类组件中使用 Hook,但您绝对可以将类和函数组件与 Hook 混合在一个树中。

,

您不能在类组件中使用钩子,而不是使用类组件,您可以将钩子与功能组件一起使用。

import React,{Component,useEffect} from 'react';
import {SafeAreaView,useSafeAreaInsets} from 'react-native-safe-area-context';

const Screen = () => {
const getNotchHeight = ()=> {
    const insets = useSafeAreaInsets();
    console.log('insets',insets);
  }
   useEffect = (()=>{
  getNotchHeight();
  },[])
}


,

const Screen = () => {
const getNotchHeight = ()=> {
    const insets = useSafeAreaInsets();
    console.log('insets',[])
}

An invalid character [32] was present in the Cookie value 错误

今天在做 cookie 部分的 demo 的时候出现了一个错误 Servlet 部分的代码如下

 1 Date data=new Date();
 2         SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
 3         String Last = format.format(data);
 4 //        System.out.println(Last);
 5         
 6         
 7         Cookie cookie =new Cookie("Lastname",Last);
 8         cookie.setMaxAge(60*10*500);
 9         response.addCookie(cookie);
10         //获得用户携带的cookie
11         String last=null;
12         Cookie[] cookies = request.getCookies();
13         if(cookies!=null){
14             for(Cookie coo:cookies){
15                 if("Lastname".equals(coo.getName())){
16                     last = coo.getValue();
17                     
18                 }
19             }
20         }
21         
22         response.setContentType("text/html;charset=utf-8");
23         if(last==null){
24             
25             response.getWriter().write("您是第一次访问");
26         }else{
27             response.getWriter().write("你上次访问的时间为"+last);
28         }

再访问该 Servlet 的时候页面就为 500,并报异常 An invalid character [32] was present in the Cookie value,

 

后来发现 32 对应的编码是空格,后来发现

SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");代码中产生了空格,后改为
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd-hh:mm:ss");就可正常访问了

 

 

android – 如何使用“CookieManager :: removeAllCookies(ValueCallback callback)”

android – 如何使用“CookieManager :: removeAllCookies(ValueCallback callback)”

我是 java的新手并尝试使用CookieManager :: removeAllCookies(ValueCallback回调)方法删除WebView cookie.无法确定必须将哪些值传递给removeAllCookie方法.

文档https://developer.android.com/reference/android/webkit/ValueCallback.html和https://developer.android.com/reference/android/webkit/CookieManager.html#getInstance%28%29没有说明如何使用它.

我的理解是ValueCallback类似于c模板.但无法理解为什么需要传递一个对象来删除cookie.

解决方法

从文档:

If a ValueCallback is provided,onReceiveValue() will be called on the current thread’s Looper once the operation is complete. The value provided to the callback indicates whether any cookies were removed. You can pass null as the callback if you don’t need to kNow when the operation completes or whether any cookies were removed

所以你可以做到这一点

CookieManager.getInstance().removeAllCookies(new ValueCallback<Boolean>() {
           @Override
           public void onReceiveValue(Boolean value) {
               Log.d(TAG,"onReceiveValue " + value);
           }
       });

要么

CookieManager.getInstance().removeAllCookies(null);

此方法在API级别21中引入.如果您支持旧版本,则可能必须提供类似的内容.

if(API Level >= 21){
     CookieManager.getInstance().removeAllCookies(null);
}else{
  CookieManager.getInstance().removeAllCookie();
}

angular-cli6使用ng serve --o 控制台报错Invalid Host Header

angular-cli6使用ng serve --o 控制台报错Invalid Host Header

配置文件需要修改node_modules里找

在node_modules里找到angular-devkit --> build-angular --> src --> dev-server里的schema.json,里面都是配置项,找到disableHostCheck,将default值设置为true即可。

修改后需要重新ng serve --o运行项目。

今天关于react使用ant design RangePicker 报错invalid hook callreact.createelement type is invalid的讲解已经结束,谢谢您的阅读,如果想了解更多关于"Invariant Violation: Invalid hook call. Hooks can only~~" 引入react-native-safe-area-context时报错、An invalid character [32] was present in the Cookie value 错误、android – 如何使用“CookieManager :: removeAllCookies(ValueCallback callback)”、angular-cli6使用ng serve --o 控制台报错Invalid Host Header的相关知识,请在本站搜索。

本文标签:

上一篇同时使用 Ant Design of React 中 Mention 和 Form(antd两个form互不影响)

下一篇react中报错Failed to set an indexed property on 'CSSStyleDeclaration': Index property setter is not supported