@visactor/react-vchart
Version:
The react version of VChart 4.x
34 lines (32 loc) • 1.59 kB
JavaScript
var __rest = this && this.__rest || function(s, e) {
var t = {};
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
if (null != s && "function" == typeof Object.getOwnPropertySymbols) {
var i = 0;
for (p = Object.getOwnPropertySymbols(s); i < p.length; i++) e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
}
return t;
};
import React, { useRef, useState, useLayoutEffect } from "react";
export default function withContainer(Comp, name = "ChartContainer", getProps) {
const Cls = React.forwardRef(((props, ref) => {
const container = useRef(null), [inited, setInited] = useState(!1), {className: className, style: style, width: width, height: height, id: id} = props, options = __rest(props, [ "className", "style", "width", "height", "id" ]);
return useLayoutEffect((() => {
setInited(!0);
}), []), React.createElement("div", {
ref: container,
id: id,
className: className,
style: Object.assign({
position: "relative",
height: height || "100%",
width: width || "100%"
}, style)
}, inited ? React.createElement(Comp, Object.assign({
ref: ref,
container: container.current
}, getProps ? getProps(options) : options)) : React.createElement(React.Fragment, null));
}));
return Cls.displayName = name || Comp.name, Cls;
}
//# sourceMappingURL=withContainer.js.map