minhtranite / react-tooltip-component Goto Github PK
View Code? Open in Web Editor NEWReact tooltip component.
React tooltip component.
I don't see any need to continue firing off the callbacks when you're moving within the element. For me, mousemove has resulted in some tooltips having instability/jittery effects. By using mouseenter/mouseleave, you completely bypass that because the position only gets calculated once.
Just curious if this was an important design decision. Otherwise, I'd switch the events you set up listeners on.
I'm getting this error while using the react-tooltip-component on the server side.
/front/node_modules/react-tooltip-component/lib/Tooltip.js:188
container: document.body,
^
ReferenceError: document is not defined
at /Users/rloubradou/workspace/front/node_modules/react-tooltip-component/lib/Tooltip.js:188:18
Setting container: null fixes the issue, and the component is still functional.
If you check the value of title is not a string, assume that it is a react element, this allows for the tooltip to render anything in the tooltip with no issues
renderTooltip = (element) => {
if (typeof this.props.title === 'string') {
element.textContent = this.props.title;
} else {
ReactDOM.render(this.props.title, element);
}
};
componentDidMount = () => {
// Removed code
let tooltipContentEl = document.createElement('div');
tooltipContentEl.className = 'tooltip-inner';
this.renderTooltip(tooltipContentEl);
// Removed code
};
componentDidUpdate = () => {
this.tooltipEl.className = 'tooltip ' + this.props.position;
this.renderTooltip(this.tooltipEl.childNodes[1]);
};
(Notice how the second text is strong)
By doing this I can also use React.Fragment
to allow direct rendering to that tooltip element
<Tooltip title={<React.Fragment>Test <strong>Test</strong></React.Fragment>}>{/*Removed*/}</Tooltip>
Love the component, thanks!
However, there is no License file in the directory of the project nor the readme.
I see it's stated in the package.json however as in other projects, its convention to put it in the root directory under the file name LICENSE.
May I suggest the MIT license such as in this project
https://github.com/reactjs/react-tabs/blob/master/LICENSE
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.