react-jsx

Change page background color with each route using ReactJS and React Router?

喜你入骨 提交于 2019-12-12 12:21:55
问题 How can I change the browsers background color when going to a new route, using ReactJS and React Router? See my EDIT's below for ideas I figured out along the way: I can get this working on the <div> in each page view, but I need it working on the full background so the full browser window shows the background. I playing with jQuery, but wondering if that's even the right way to solve this? I'm also trying to use React.DOM.body , but not getting it working: render: function() { return ( <div

Google Map Api Marker not showing with Reactjs

与世无争的帅哥 提交于 2019-12-12 10:10:37
问题 I am trying to display a google map with a marker. I am using React.js. The map displays in the correct location, but the marker does not show and I get multiple 'object is not extensible' error in the browser console The code looks like this /** @jsx React.DOM */ var Map = React.createClass({ initialize: function() { var lat = parseFloat(this.props.lat); var lng = parseFloat(this.props.lon); var myPosition = new google.maps.LatLng(lat,lng); var mapOptions = { center: myPosition, zoom: 8 };

Nested comments in Reactjs

痞子三分冷 提交于 2019-12-12 08:14:40
问题 I have the following json: { "comments":[ { "id":1, "comment_text":"asdasdadasdsadsadadsa", "author":"adsfasdasdsad", "post_id":1, "ancestry":null, "archived":false, "created_at":"2014-10-16T23:16:44.173Z", "updated_at":"2014-10-16T23:16:44.173Z", "is_moderated":false, "avatar_url":null, "slug":null, "blog_id":2, "children":[ ] }, { "id":2, "comment_text":"idlsfghlskdhvbsldfhjdslifds\nzf\ndsf\nds\nf\ns\nf\ns\nfds\nfsdjghfsdligjhsepfiguhefdliguhefldiughfeliughnfesg\nf\nsg\ns\ng\ns\ndf\nsd\nf

React.js: Is it possible to namespace child components while still using JSX to refer to them?

隐身守侯 提交于 2019-12-12 08:01:54
问题 So let's say I have a component called ImageGrid and it is defined as below: window.ImageGrid = React.createClass({ render: function() { return ( <div className="image-grid"> <ImageGridItem /> </div> ); } }); As you can see it includes a child react component called ImageGridItem . Which is defined below. window.ImageGridItem = React.createClass({ render: function() { return ( <div className="item-container">something</div> ); } }); This works fine as long as both are directly properties of

Setting Highcharts piechart chartDefaults from calling jsx file in React

試著忘記壹切 提交于 2019-12-12 06:12:30
问题 I am using the following syntax to render a Highcharts PieChart. var ContainingClass = React.createClass({ render: function() { return ( <PieChart title={this.props.title} series={this.props.series} /> ); }, }); This works well, but I need to overwrite the tooltip field in PieChart . What can I change in ContainingClass to make this happen? Edit: Here is a sample fiddle with PieChart - http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts

React child component receiving props as undefined

白昼怎懂夜的黑 提交于 2019-12-12 05:59:35
问题 I have component Comp1 and it's child Comp2 . The state of markers is set in the parent component to this object: var MARKER_ITEMS = { "item1" : { "cat" : "wow", "img" : "slide", "info" : "bike", "key" : "1" }, "item2" : { "cat" : "omg", "img" : "slide", "info" : "4x4", "key" : "2" } }; When I try to generate a Comp2 for each object with loadash _.map , the props get passed down as undefined. jsfiddle 回答1: Your code works but you're using the key name as a props. key is a special reserved

MVC-ReactJS button onclick event not get fired

不羁岁月 提交于 2019-12-12 04:59:09
问题 I am creating simple stuff seeking for capturing button click event to some text or get some alert. ReactJS JSX code is pasted below: var SearchBar = React.createClass({ getInitialState: function() { return {message: "test"}; }, test1: function(e) { alert('hi'); this.setState({message: "New Message"}); }, render: function() { var self = this; return ( <div> <button onClick={self.test1}>Change Message</button> {this.state.message} </div> ); }, }); I use above SearchBar component in MVC cshtml

How to apply style for the inbuilt markdown tags?

孤者浪人 提交于 2019-12-12 04:57:25
问题 I am a learner for reactjs, i am trying to create a text editor, where i want to do indentation for the text which is selected based on the start and end index. I can get the selected text, and i can apply bold, italic using marked package like ** for bold, and _ for italic,etc,.. but i cannot apply the style like text align, text decoration for the marked tags How can i apply styles for the marked tags? what should i do? is there any other way to do? 回答1: You would need to define CSS rules

Why can't string variable be used in <Image source={}/>? (React Native)

情到浓时终转凉″ 提交于 2019-12-12 03:04:26
问题 I am trying to do the following: var itemImage = '../img/image1.jpg' return( <Image source={require(itemImage)} /> but it keeps saying the error: Requiring unknown module '../img/image1.jpg'. But when I directly put in: '../img/image1.jpg' inside require() then it works. What may be the issue? Any guidance or insight would be appreciated. EDIT *** I have the following in my constructor as my dataSource: this.state = {dataSource: ds.cloneWithRows([{name: '../img/item1.jpg'}, {name: '../img

Two function in a event on React-Native

半世苍凉 提交于 2019-12-12 02:59:15
问题 How to put two function in a event like onValueChange? I tried with onValueChange={(selected) => this.setState({selected}),this.state.eventOnChange}> 回答1: What about: onValueChange={(selected) => { this.setState({selected}); this.state.eventOnChange(); }} 回答2: Component.setState() is asynchronous and may be locked on the second call while it is still doing the first. Do the second call in a callback like this: onValueChange= { (selected) => { this.setState( {category:selected},() => {this