आपको रेक्टजेएस के लिए एएसआरआई एपीआई आयात करने की आवश्यकता नहीं है। चूंकि प्रतिक्रिया फ़ाइल अंततः एक जेएस फ़ाइल में संकलित हो जाएगी, इसलिए आपको एएसआरई भागों को लिखने की आवश्यकता है और डोम नोड को संभालने के लिए ReactJS भाग को मिलाकर, जो ReactJS का मुख्य उद्देश्य है।
नीचे दिए गए लिंक से एक नमूना
define([
'react',
'esri/toolbars/draw',
'esri/geometry/geometryEngine',
'dojo/topic',
'dojo/on',
'helpers/NumFormatter'
], function(
React,
Draw, geomEngine,
topic, on,
format
) {
var fixed = format(3);
var DrawToolWidget = React.createClass({
getInitialState: function() {
return {
startPoint: null,
btnText: 'Draw Line',
distance: 0,
x: 0,
y: 0
};
},
componentDidMount: function() {
this.draw = new Draw(this.props.map);
this.handler = this.draw.on('draw-end', this.onDrawEnd);
this.subscriber = topic.subscribe(
'map-mouse-move', this.mapCoordsUpdate
);
},
componentWillUnMount: function() {
this.handler.remove();
this.subscriber.remove();
},
onDrawEnd: function(e) {
this.draw.deactivate();
this.setState({
startPoint: null,
btnText: 'Draw Line'
});
},
mapCoordsUpdate: function(data) {
this.setState(data);
// not sure I like this conditional check
if (this.state.startPoint) {
this.updateDistance(data);
}
},
updateDistance: function(endPoint) {
var distance = geomEngine.distance(this.state.startPoint, endPoint);
this.setState({ distance: distance });
},
drawLine: function() {
this.setState({ btnText: 'Drawing...' });
this.draw.activate(Draw.POLYLINE);
on.once(this.props.map, 'click', function(e) {
this.setState({ startPoint: e.mapPoint });
// soo hacky, but Draw.LINE interaction is odd to use
on.once(this.props.map, 'click', function() {
this.onDrawEnd();
}.bind(this));
}.bind(this))
},
render: function() {
return (
<div className='well'>
<button className='btn btn-primary' onClick={this.drawLine}>
{this.state.btnText}
</button>
<hr />
<p>
<label>Distance: {fixed(this.state.distance)}</label>
</p>
</div>
);
}
});
return DrawToolWidget;
});
नीचे दिए गए लिंक जहां विस्तार से जानकारी प्राप्त कर सकते हैं यहाँ है।
http://odoe.net/blog/esrijs-reactjs/
https://geonet.esri.com/people/odoe/blog/2015/04/01/esrijs-with-reactjs-updated
एफवाईआई, आप esri-loader का उपयोग करते समय ArcGIS API को आलसी लोड करने के लिए _need_ नहीं करते हैं। इसके बजाए, आप ARGIS एपीआई को index.html में स्क्रिप्ट टैग के माध्यम से लोड कर सकते हैं जैसे कि < '। इस मामले में, 'घटकडिडमाउंट()' के लिए उपरोक्त कोड बस 'this._createMap() 'होगा। –