Skip to content

Commit

Permalink
[text] add innerRef prop
Browse files Browse the repository at this point in the history
  • Loading branch information
hshoff committed Aug 23, 2018
1 parent 128d35f commit 10887e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vx-text/src/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Text extends Component {
angle,
lineHeight,
capHeight,
innerRef,
...textProps
} = this.props;
const { wordsByLines } = this.state;
Expand Down Expand Up @@ -121,7 +122,13 @@ class Text extends Component {
}

return (
<svg x={dx} y={dy} fontSize={textProps.fontSize} style={{ overflow: 'visible' }}>
<svg
ref={innerRef}
x={dx}
y={dy}
fontSize={textProps.fontSize}
style={{ overflow: 'visible' }}
>
<text {...textProps} textAnchor={textAnchor}>
{wordsByLines.map((line, index) => (
<tspan x={x} dy={index === 0 ? startDy : lineHeight} key={index}>
Expand Down Expand Up @@ -151,7 +158,8 @@ Text.propTypes = {
angle: PropTypes.number,
textAnchor: PropTypes.oneOf(['start', 'middle', 'end', 'inherit']),
verticalAnchor: PropTypes.oneOf(['start', 'middle', 'end']),
style: PropTypes.object
style: PropTypes.object,
innerRef: PropTypes.func
};

export default Text;

0 comments on commit 10887e8

Please sign in to comment.