React使用portal提示 The types returned by 'render()' are incompatible between these types. Type 'ReactPortal' is not assignable to type 'ReactNode'. Type '{}' is not assignable to type 'ReactNode'.
原因:组件返回了个不是<></>的东西
原先代码:
export default class Index extends React.PureComponent {
render() {
return reactDOM.createPortal(
<div>传送内容</div>,
document.body
);
}
}
结局方案:
export default class Index extends React.PureComponent {
render() {
return <>
reactDOM.createPortal(
<div>传送内容</div>,
document.body
);
</>
}
}
React使用portal提示 The types returned by 'render()' are incompatible between these types. Type 'ReactPortal' is not assignable to type 'ReactNode'. Type '{}' is not assignable to type 'ReactNode'.的更多相关文章
- block中出现此种报错: Incompatible block pointer types initializing 'float (^__strong)(float, float)' with an expression of type 'int (^)(float, float)'
当block(代码块)的返回值是float时,应注意的地方:定义的返回值类型一定要与return的返回值类型一样 我们以两个数的四则运算来举例 在main.m文件中的四则运算中,我采用两种返回值类型( ...
- WebStorm开发工具设置React Native智能提示
最近在做React Native开发的时候,相信大家一般会使用WebStorm,Sublime,Atom等等开发工具.二之前搞前端的对WebStorm会很熟悉,WebStorm最新版是WebStorm ...
- 解决 React Native:The development server returned response error code: 404
解决方法: 打开android/app/build.gradle compile 'com.facebook.react:react-native:+' 修改为: compile ("com ...
- vue2.XX 提示[Vue warn]: Error in render: "TypeError: Cannot read property 'img' of undefined"
item 是向后台请求的一条数据,里面包含img,但是却提示img未定义 父组件向子组件传递数据时, 子组件 具体代码: <img :src="item.img" /> ...
- sys/types.h fcntl.h unistd.h sys/stat.h
sys/types.h 是Unix/Linux系统的基本系统数据类型的头文件,含有size_t,time_t,pid_t等类型. 在应用程序源文件中包含 <sys/types.h> 以访问 ...
- 从零开始配置TypeScript + React + React-Router + Redux + Webpack开发环境
转载请注明出处! 说在前面的话: 1.为什么不使用现成的脚手架?脚手架配置的东西太多太重了,一股脑全塞给你,我只想先用一些我能懂的库和插件,然后慢慢的添加其他的.而且自己从零开始配置也能学到更多的东西 ...
- react学习一篇就够了
webstrom自动格式化代码 命令 js框架 MVC 安装 npm install create-react-app -g 生成项目(项目名npm发包包命名规范 /^[a-z0-9_-]$/) cr ...
- React高级指南
高级指南 1.深入JSX: 从本质上讲,JSX 只是为 React.createElement(component, props, ...children) 函数提供的语法糖. 因为 JSX 被编译为 ...
- 【Web技术】401- 在 React 中使用 Shadow DOM
本文作者:houfeng 1. Shadow DOM 是什么 Shadow DOM 是什么?我们先来打开 Chrome 的 DevTool,并在 'Settings -> Preferences ...
- React与Typescript整合
0. Typescript Typescript对于前端来说可以说是越来越重要了,前端的很多项目都用Typescript进行了重构.这主要得益于Typescript有比较好的类型支持,在编码的过程中可 ...
随机推荐
- winform 中 label透明化
label1.BackColor = Color.Transparent;//设置背景颜色为透明 label1.Parent = pictureBox1;//将pictureBox1设为标签的父控件, ...
- vux方法
vuex 的备注 // vuex的公用数据放置处 state: { count: 0, }, // (方法) 在里面可以去修改state里面的数据(在这里面不能写异步操作) mutations: { ...
- boss直聘上看信息 但是不会显示已读
大家在boss直聘上看 想看的boss回你的信息但是又不想显示已读 可以按F12 打开控制台 查找标出文件 查看lastmsg文本里面就是最后一次发你的信息
- vue创建模板
文件-->首选项-->用户代码片段-->点击新建代码片段--取名vue.json 确定 { "生成vue 模板": { "prefix": & ...
- ubuntu18.04系统下RealTek RTL 8852BE网卡没有WiFi驱动
1 打开终端:sudo apt-get update2 安装必要的包:sudo apt-get install make gcc linux-headers-$(uname -r) build-ess ...
- blog2对PTA4,5,6集的习题总结
一. 前言 通过本三次PTA得题目,我受益匪浅.题量的话不算太多,但是题目难度有些大.在本次PTA第六次题目集中,题目难度较中,第四次题目集第一道水文数据处理与第五次题目集的查询关键字出现次 ...
- Android版本历史
版本 Code Name 代号 API 日期 NDK 1.0 Astro 铁臂阿童木 1 1.1 Bender, Petit Four 发条机器人 2 1.5 Cupcake 纸杯 ...
- 杂:python_windows标准输出带颜色
import ctypes handle = ctypes.windll.kernel32.GetStdHandle(-11) # -11 for output -10 for input - ...
- UI工具
sketch figma Adobe Photoshop Adobe Illustrator adobe xd
- TIDB-DM数据迁移第一部(安装部署)
官方连接: https://docs.pingcap.com/zh/tidb/stable/dm-overview 架构: 1.安装DM download https://tiup-mirrors.p ...