react-jsx

How to make IntelliJ IDEA resolve webpack requires out of node_modules directory?

廉价感情. 提交于 2019-11-30 17:30:17
IntelliJ cannot resolve javascript modules called with webpack requires which are not inside the node_modules directory Imagine this project structure: `- project |- node_modules | `- react | `- addons.js |- webpack.config.js |- util | `- tool.js `- src |- components | `- uno.jsx `- two.jsx This is my webpack config // webpack.config.js var path = require('path'); module.exports = { resolve: { root: [ path.resolve('./src'), path.resolve('./') ] } ... } And this is how I use webpack's require // two.js var React = require('react/addons'); var One = require('components/one'); var Tool = require(

Babel 6 react JSX transformer - disable strict

放肆的年华 提交于 2019-11-30 17:26:47
Issue I'm using babel 6 for react JSX transforms. However I'm not using the react preset, I am ONLY using the 'transform-react-jsx' plugin (and trying strict-mode disable option), here is my .babelrc { "plugins": [ ["transform-react-jsx"] ], "sourceMaps": true, "strictMode": false } However I have required a thirdparty javascript that uses 'with' (out of my control) which emits following error: [SyntaxError: foo.js: 'with' in strict mode .. ] So I need to disable strict mode, This is same problem as this issue however I am NOT using es6/es2015 stuff, only jsx transforms. With babel 6 there is

React onClick event

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 17:23:55
I'm missing something. Here's a very simple hello world, the goal is to just fire an alert event onClick. The event does fire when the page loads, but not when I click the button. I appreciate the help. Here's a jsFiddle to make it easier to see: jsFiddle var Hello = React.createClass({ render: function() { return <button onClick={alert("Hello World!")}> Click Me </button>; } React.render(<Hello />, document.getElementById('container')); I think you're going about this wrong, because ReactJS is just JavaScript I don't think your way of firing this event will work. Your onClick should fire a

How to get value of textbox in React?

喜欢而已 提交于 2019-11-30 17:08:58
I just started using React.js, and I'm just not sure whether there is a special way to get the value of a textbox, returned in a component like this: var LoginUsername = React.createClass({ render: function () { return ( <input type="text" autofocus="autofocus" onChange={this.handleChange} /> ) }, handleChange: function (evt) { this.setState({ value: evt.target.value.substr(0, 100) }); } }); As described in documentation You need to use controlled input . To make an input - controlled you need to specify two props on it onChange - function that would set component state to an input value every

Debugging JSX using browser / plugins

删除回忆录丶 提交于 2019-11-30 14:42:52
问题 Is there a way to debug JSX files? I am unable to see the .jsx files when I check the resources tab in either safari / chrome. Can we use a debugger ? 回答1: After you install the Chrome Extension open the devTool (f12) and you can see: A new react tab - use to inspecting the react elements (like the regular inspect). In source tab (left panel) a new App list where u can see the JSX files and set break points in side your code. NOTE: it might be necessary to restart chrome to get it going 回答2:

Do I need to import React for stateless functional components?

点点圈 提交于 2019-11-30 13:55:56
问题 All around me (e.g. blog posts, code) I see code for React stateless functional components in which React is imported even though it's never used. import React, { PropTypes } from 'react'; function MyComponent({ foo, bar }) { ... return ...; } MyComponent.propTypes = { foo: PropTypes.string.isRequired, bar: PropTypes.func.isRequired } export default MyComponent; I'd argue there is no need for importing React into functional components, and have been assuming it's just a vestige from when the

Child to parent communication in React (JSX) without flux

為{幸葍}努か 提交于 2019-11-30 13:27:44
I'm really new to React, and I'm pulling my hair out trying to solve what seems to me to be a simple problem. Here's a picture of the component I've built. Color Picking Component What I'm trying to accomplish seems trivial, but literally every article I've read explaining what to do has told me something different, and not one of the solutions has worked. It breaks down to this: When a user clicks on a tag, it builds out a tray and loops through an array of colors to build color buttons. When a color button is clicked it needs to pass which color was clicked to its parent component and run a

How do I use react.js without a bundler?

守給你的承諾、 提交于 2019-11-30 12:24:25
Recently I have been playing around with react.js and I like the speed that I can develop working UI components. I have now created quite a few components and I would like to distribute some of them among different .jsx files. Every thing I've read says that I should be using a bundler like browserify or webpacker whenever moving to production. However I am against this idea. Part of the reason I like developing in javascript is because its a scripted language and there is no compiler to muck around with. If I wanted to mess around with build chains and the like I would probably just do my

Debugging JSX using browser / plugins

折月煮酒 提交于 2019-11-30 11:25:53
Is there a way to debug JSX files? I am unable to see the .jsx files when I check the resources tab in either safari / chrome. Can we use a debugger ? After you install the Chrome Extension open the devTool (f12) and you can see: A new react tab - use to inspecting the react elements (like the regular inspect). In source tab (left panel) a new App list where u can see the JSX files and set break points in side your code. NOTE: it might be necessary to restart chrome to get it going There is Chrome Extension which adds another tab to Developer Tools and allows debug React Components. You can

Listen to keypress for document in reactjs

青春壹個敷衍的年華 提交于 2019-11-30 10:52:28
问题 I want to bind to close the active react bootstrap popover on escape press .Here is the code _handleEscKey:function(event){ console.log(event); if(event.keyCode == 27){ this.state.activePopover.hide(); } }, componentWillMount:function(){ BannerDataStore.addChangeListener(this._onchange); document.addEventListener("click", this._handleDocumentClick, false); document.addEventListener("keyPress", this._handleEscKey, false); }, componentWillUnmount: function() { BannerDataStore