React Portal All In One
React Portal All In One
react multi root
https://reactjs.org/docs/portals.html
https://zh-hans.reactjs.org/docs/portals.html
ReactDOM.createPortal(child, container)
demo
https://codepen.io/gaearon/pen/yzMaBd
Modal
createPortal
https://zh-hans.reactjs.org/docs/portals.html
import React, { } from 'react';
import { createPortal } from 'react-dom';
function BreadcrumbPortal (props) {
const el = document.getElementById('breadcrumb');
return createPortal(
props.children,
el,
);
}
export default BreadcrumbPortal;
refs
2017
https://github.com/reactjs/reactjs.org/commits/master/content/docs/portals.md
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14312266.html
未经授权禁止转载,违者必究!