EzDevInfo.com

JSX

JSX - a faster, safer, easier JavaScript JSX - a faster, safer, easier JavaScript

React JSX: Access Props in Quotes

In JSX, how do you reference a value from props from inside a quoted attribute value?

For example:

<img className="image" src="images/{this.props.image}" />

The resulting HTML output is:

<img class="image" src="images/{this.props.image}">

Source: (StackOverflow)

"Console.log" with Photoshop Scripting - ExtendedScript Toolkit

I'm doing a bit of Photoshop scripting for the first time and it sure would be great to have a console.log-like function to output array and object values in the Javascript console of the ExtendScript Toolkit App.

Is there an equivalent function?


Source: (StackOverflow)

Advertisements

React.js: how to decouple jsx out of javascript

Is there any way to move the jsx from a component's render function to a separate file? If so, how do I reference the jsx in the render function?


Source: (StackOverflow)

Typescript for Facebook React

I've been looking into React lately and was hoping to use JSX and typescript. I haven't been able to find any resources on this or type definitions for React.

Can you use Typescript with JSX and are type definitions available?


Source: (StackOverflow)

coffeescript-react (.cjsx) Support in Webstorm

Is there a way to get any kind of syntax highlighting for .cjsx (jsx in coffeescript) files in WebStorm?

Currently, I'm using a Sublime plugin, which is great, but I'd prefer to stay in WebStorm if possible. I understand WebStorm supports TextMate bundles, so that may be a viable option but I couldn't find one for cjsx.


Source: (StackOverflow)

React: Keyboard Event Handlers All 'Null'

I'm unable to get any of the React SyntheticKeyboardEvent handlers to register anything except null for the event properties.

I've isolated the component in a fiddle and am getting the same result as in my application. Can anyone see what I'm doing wrong?

http://jsfiddle.net/kb3gN/1405/

var Hello = React.createClass({
    render: function() {
      return (
      <div>
        <p contentEditable="true"
           onKeyDown={this.handleKeyDown}
           onKeyUp={this.handleKeyUp}
           onKeyPress={this.handleKeyPress}>Foobar</p>
        <textarea
           onKeyDown={this.handleKeyDown}
           onKeyUp={this.handleKeyUp}
           onKeyPress={this.handleKeyPress}>
        </textarea>
        <div>
          <input type="text" name="foo" 
           onKeyDown={this.handleKeyDown}
           onKeyUp={this.handleKeyUp}
           onKeyPress={this.handleKeyPress} />
        </div>
      </div>
      );
    },

    handleKeyDown: function(e) {
      console.log(e);
    },

    handleKeyUp: function(e) {
     console.log(e);
    },

    handleKeyPress: function(e) {
     console.log(e); 
    }
});

React.renderComponent(<Hello />, document.body);

Source: (StackOverflow)

React JSX: selecting "selected" on selected