Skip to content

Commit 76fce97

Browse files
committed
React 15 compat & node label keys
node label key catch no props custom mark let facetcontroller accept a react15Wrapper because 15 doesn't support Fragments
1 parent 9b22049 commit 76fce97

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

src/components/FacetController.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function validFrameProps(originalProps, frameType) {
3131
}
3232

3333
type FacetControllerProps = {
34-
children: Node
34+
children: Node,
35+
react15Wrapper: Element<*>
3536
}
3637

3738
type Props = FacetControllerProps & OrdinalFrameProps & XYFrameProps
@@ -177,6 +178,16 @@ class FacetController extends React.Component<Props, State> {
177178
})
178179

179180
render() {
181+
const Wrapper = this.props.react15Wrapper
182+
183+
if (Wrapper) {
184+
return React.cloneElement(
185+
Wrapper,
186+
undefined,
187+
this.processFacetController(this.props, this.state)
188+
)
189+
}
190+
180191
return (
181192
<React.Fragment>
182193
{this.processFacetController(this.props, this.state)}

src/components/NetworkFrame.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,11 @@ class NetworkFrame extends React.Component<Props, State> {
15421542
nodeSizeAccessor
15431543
})
15441544
} else if (d.type === "basic-node-label") {
1545-
return <g transform={`translate(${d.x},${d.y})`}>{d.element}</g>
1545+
return (
1546+
<g key={d.key} transform={`translate(${d.x},${d.y})`}>
1547+
{d.element}
1548+
</g>
1549+
)
15461550
} else if (d.type === "react-annotation" || typeof d.type === "function") {
15471551
return svgReactAnnotationRule({
15481552
d,

src/components/svg/networkDrawing.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export const drawEdges = ({
345345
})
346346
if (
347347
renderedCustomMark &&
348+
renderedCustomMark.props &&
348349
(renderedCustomMark.props.markType !== "path" ||
349350
renderedCustomMark.props.d)
350351
) {

src/components/visualizationLayerBehavior/general.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export function createPoints({
9494

9595
if (
9696
renderedCustomMark &&
97+
renderedCustomMark.props &&
9798
!renderedCustomMark.props.markType &&
9899
(!canvasRender || canvasRender(d.data, i) !== true)
99100
) {

src/docs/components/FacetControllerDocs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ export default class FacetControllerDemo extends React.Component {
265265
pieceIDAccessor="color"
266266
sharedRExtent={true}
267267
axis={{ orient: "left" }}
268+
react15Wrapper={
269+
<div style={{ display: "flex", border: "2px solid gold" }} />
270+
}
268271
>
269272
<OrdinalFrame data={orData} />
270273
<XYFrame

0 commit comments

Comments
 (0)