question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to use reactelement for reference line

See original GitHub issue

Do you want to request a feature or report a bug?

Bug report

What is the current behavior?

When i use plain text for the label of a reference line, everything works ok. But say i put in a react element (Ie <span>hello</span>), nothing displays.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: http://jsfiddle.net/ndLhnegs/).

<AreaChart ....>
   .....
   <ReferenceLine label={<span>hello</span>} />
</AreaChart>

The resulting HTML

<g class="recharts-layer recharts-reference-line">
  <line x="23" stroke="green" fill="none" fill-opacity="1" stroke-width="1" x1="469.15789473684214" y1="270" x2="469.15789473684214" y2="20" class="recharts-reference-line-line"></line>
  <span content="[object Object]" viewBox="[object Object]" offset="5">hello</span>
</g>

What is the expected behavior?

Should see “hello” on the reference line

Which versions of Recharts, and which browser / OS are affected by this issue? Did this work in previous versions of Recharts?

recharts@^1.5.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
cbarrafordcommented, May 15, 2019

@xile611 well im actually trying to render something more complicated than “hello”, but since the simple use case doesn’t work as documented, i figured i’d start with that.

What I’m actually trying to accomplish is saying hello with a 90 degree rotation

0reactions
olelivalifecommented, Nov 18, 2020

This works (but not in IE…)

 <foreignObject x="40" y="40" width="100" height="100">
    <div xmlns="http://www.w3.org/1999/xhtml">test</div>
  </foreignObject>
Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - No component displayed when adding a custom label ...
Currently, we can customise the label using an object but when passing our own element in nothing is rendered. <ReferenceLine y={dataLimits.lL} ...
Read more >
JSX In Depth - React
Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the...
Read more >
Understanding common frustrations with React Hooks
React Hooks can be frustrating despite their popularity and widespread use. Learn about some of the drawbacks to using React Hooks.
Read more >
Type Reference - JavaScript. Flow
A reference for all the utility Flow types exported by the React module.
Read more >
How To Create React Elements with JSX - DigitalOcean
That means you can't use certain words in any JavaScript code. ... add the following highlighted lines to reference an attribute:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found