JavaScript ReactJS - how create two or more components in same page

You can just iterate the result from getElementsByClassName:

function renderEls(elements) {
    for (var i = 0; i < elements.length; i++) {
        if( $(elements[i]).attr('comp-url') !== undefined ) {
            var url = $(elements[i]).attr('comp-url');
        }
        ReactDOM.render(<MyMap url={url} />, elements[i]);
    }
}

renderEls(document.getElementsByClassName("MyMap"));
Answer:1

I use jsx with react, you can create a react component that holds all your maps

var MapContainer = React.createClass({
    renderMyMaps: function() {
        return this.props.myMaps.map( function(map, index) {
            return <MyMap url={map.url} widthMap={} heightMap={}/>
            }
        )
    }

    render: function() {
        return (
            <div className="mapContainer">
                { this.renderMyMaps() }
            </div>
        )
    }
})

var MyMap = React.createClass({displayName: "MyMap",
    getDefaultProps: function() {
        return {
            widthMap: 600,
            heightMap: 450
        }
    },
    getInitialState: function() {
        return {
            url: ''
        }
    },
    render: function() {
        return (
            <iframe
                src={this.props.url}
                width={this.props.widthMap}
                height={this.props.heightMap}
                frameborder=0
                allowfullscreen={true} />
        );
    }
});


var maps = [
    {url: '', widthMap: '', heightMap: ''},
    ...
]

ReactDOM.render(<MapContainer myMaps={maps} />,document.getElementById('MyMap'));

with this approach, it might be easier for you to just add to the myMaps property.

you can also just create a container that will output its children.

render(){
    return (
        <div className="MapContainers">
            { this.props.children }
        </div>
    )
 }

the just put all the MyMap that you will create inside MapContainer

<MapContainer>
    <MyMap />
    ...
</MapContainer>
Answer:2

I have a code for table and search text : <div class="table-responsive"> Search Data : <input type="text" class="txtSearch" id="search_field"> <div class="tableFixHead"> ...

I have a code for table and search text : <div class="table-responsive"> Search Data : <input type="text" class="txtSearch" id="search_field"> <div class="tableFixHead"> ...

  1. change content inside div jquery
  2. change content inside iframe
  3. change content inside div css
  4. javascript change content inside iframe
  5. javascript change content inside div
  6. javascript change content inside span

I have some problems with css manipulation with jQuery. Here is what I need to do. I have these three picture. Each are a representation of a person. When we click on one of those, this div appears: ...

I have some problems with css manipulation with jQuery. Here is what I need to do. I have these three picture. Each are a representation of a person. When we click on one of those, this div appears: ...

I am working on a javascript problem for fun that is supposed to take a string and return nested arrays that contain one array for every character that repeats. The groups should have the following ...

I am working on a javascript problem for fun that is supposed to take a string and return nested arrays that contain one array for every character that repeats. The groups should have the following ...

  1. finding last index of string in java
  2. finding last index of a string in oracle

I've got a small problem in my javascript which i am stuck on for a while now. What i did is : Create an empty table. Generate the tr/td tags and values inside the table(from JSON-object). for (...

I've got a small problem in my javascript which i am stuck on for a while now. What i did is : Create an empty table. Generate the tr/td tags and values inside the table(from JSON-object). for (...