react-jsx

Browserify fails to create bundle with babelify transform (TypeError: Path must be a string.)

╄→гoц情女王★ 提交于 2019-12-09 15:55:43
问题 I've written a gulp task to compile my .jsx and .js scripts into a bundle using watchify and babelify as a transform. For some reason my gulp script seems to be choking on the transform and I'm not sure why: gulp.task('browserify', function() { var bundle = watchify(browserify('./app/jsx/client/index.jsx', { extensions: ['.js', '.jsx'], debug: process.env.NODE_ENV === 'development' })); bundle.transform(babelify); bundle.on('update', function() { rebundle(bundle); }); function rebundle(bundle

ReactJS change background image dynamically?

吃可爱长大的小学妹 提交于 2019-12-09 14:45:44
问题 I was trying to change background image style dynamically for the following div: Here is my component for changing it, render: function() { var divImage = { backgroundImage : "url(" + this.state.song.imgSrc + "),url(" + this.state.nextImgSrc + ");" }; return ( <li> <div ref="image-pane" className="player" style={divImage}></div> </li> ) } Thanks for the help 回答1: You haven't specified when would you like to change backgroundImage , so I've created version which changes it with onClick : React

Child parent component communication in ReactJS

点点圈 提交于 2019-12-09 11:13:31
问题 I like to send the attribute properties/props/state values from child component to parent component on an event fire onDrag . I could not find proper documentation on this. Here is my code: /*** @jsx React.DOM */ var APP=React.createClass({ getInitialState:function() { return {url:'http://www.youtube.com/embed/XGSy3_Czz8k'} }, handleDrag:function(vidurl) { alert(vidurl); //i need to get child component url here. }, render:function(){ return <div> <VideoFrame src={this.state.url} /> <hr/>

Using an input field with onBlur and a value from state blocks input in Reactjs JSX?

放肆的年华 提交于 2019-12-09 02:51:23
问题 I've made a small fiddle to show the problem: http://jsfiddle.net/4TpnG/582/ When you have an input box with onBlur attached to it, and an initial value from state, input from the keyboard is blocked. When onChange is attached, it's working correctly. Why is this happening and how can this be solved? I would have expected it to accept the characters you type and update the state onBlur. var Test = React.createClass({ getInitialState: function() { return { value: "hallo" }; }, render: function

Require jsx files without specifying extension

房东的猫 提交于 2019-12-08 23:22:49
问题 I am using browserify and watchify , and would like to require() files other than the default extensions .js and .json without specifying the extension, for instance: // Not ideal (tedious) var Carousel = require('./components/Carousel/Carousel.jsx') // Ideal var Carousel = require('./components/Carousel/Carousel') I have tried --extension=EXTENSION as specified in the browserify documentation: "scripts": { "build": "browserify ./src/App.js --transform [ reactify --es6 ] > dist/script.js -v

React.js - ForEach as a first-class component?

眉间皱痕 提交于 2019-12-08 20:26:12
问题 I've heard of react-templates, but I was still wondering it was possible to make a first-class ForEach component. My end goal is to make something like this more readable: <ul> {list.map(function(item, i) { return <li>{item}</li>; })} </ul> // instead? <ul> <ForEach items="{list}"> <li>{item}</li> </ForEach> </ul> Here's my first serious attempt by passing props: var ForEach = React.createClass({ render: function(){ return ( <ul> {this.props.items.map(function(item, i) { return React.Children

Using css-loader inline with Webpack + React

独自空忆成欢 提交于 2019-12-08 19:42:01
问题 I'm building my React app with Webpack, and css-loader w/modules. I love it. Most of my stylesheets are very small, though, and I'd like to inline them within the same JSX file as my markup and JavaScript. The CSS loader I'm using right now looks like this: { test: /\.(css)$/i, loader: ExtractTextPlugin.extract("style-loader", "css-loader?modules") } In my JSX, I import my separate CSS files like this: import classNames from 'dashboard.css'; ... <div className={classNames.foo}></div>; This is

this.state.foo is different in _onChange and different in render()?

廉价感情. 提交于 2019-12-08 11:08:37
问题 In _onChange method, I wait for a change in this.state.name . On the change _updateArticle method is called: _onChange() { var team = this.getTeamState(); this.setState({name: team}); console.log(this.state.name); //"Boston Celtics" //this should have changed but it didn't this.unbind("articles"); this._updateArticle(); }, then in _updateArticle a new reference is created using this new state. _updateArticle(team) { var teamRef = new Firebase(this.props.baseUrl + team + "/results"); console

jsx command not found on mac terminal

落花浮王杯 提交于 2019-12-08 08:13:03
问题 Problem: I execute the following command from the macintosh terminal: $ jsx --watch src/ build/ I recieve the following output error from the terminal: -bash: jsx: command not found Relevant information: I am following the following tutorial: https://facebook.github.io/react/docs/getting-started.html I executed the following command from the tutorial with positive output: $ npm install -g react-tools This instruction immediately precedes the instruction that produces the error: Environment

How to convert react JSX files to simple JavaScript file [offline transformation]

耗尽温柔 提交于 2019-12-08 07:08:42
问题 I am new to react.js. Just started learning it. So my question may seems to be stupid but please answer it. I have created a simple .js file with following code: var Hello=React.createClass({ render: function(){ return (<h1>Hello World</h1>); } }); It is in JSX syntax and to convert it to simple JavaScript file I used following command: babel --preset react JSX_Files --watch --out-dir public/javascripts Here JSX_Files is my source folder and public/javascripts is the folder where I want my