Khan / react-components

khan.github.io/react-components/
MIT License
1.01k stars 99 forks source link

Tooltip: Problems getting it to work #24

Closed theogravity closed 9 years ago

theogravity commented 9 years ago

Hi there,

I'm still on React 0.11.x, and have been trying to get the tooltip to work by trying to backport what I see in the latest versions which seems to be using 0.12.x.

  1. Where are the backtick operators from? I did not find any immediate references to the backticks in the React docs.

https://github.com/Khan/react-components/blob/master/js/tooltip.jsx#L65

  1. What is the equiv for 0.11.x for

https://github.com/Khan/react-components/blob/master/js/tooltip.jsx#L192

arrowLeft: (arrowSize) => -arrowSize - 2

Is it also a 0.12 notation?

When I search for these things I get a lot of CoffeeScript results, but the file itself does not seem to be valid CoffeeScript...

Thanks for your effort and work on this component, guys!

zgotsch commented 9 years ago

The backtick strings as well as the arrow notation are both features which will be in ECMAScript 6, and are not yet supported on most browsers. The JSX transformer from Facebook will transpile them into ECMAScript 5 (if it is passed the --harmony flag), which will run in modern browsers.

The equivalent of ES6's

        var hBorder = `${this.props.width}px solid transparent`;

is roughly ES5's var hBorder = this.props.width + "px solid transparent";.

The equivalent of ES6's arrowLeft: (arrowSize) => -arrowSize - 2 is roughly ES5's arrowLeft: function(arrowSize) { return -arrowSize - 2; }.bind(this).

theogravity commented 9 years ago

Wow, thank you for the information!