stylesheet access elements using class object name code example
Example 1: javascript create element with class
Let suppose we are creating a div using javascript create element
var newDiv = document.createElement("div");
newDiv.className = "className";
Example 2: how to access array datat in class component react
import React, { Component } from 'react'
import './TourList.scss';
import Tour from '../Tour/Tour';
import { tourData } from './tourData';
export default class TourList extends Component {
state={
tours:tourData
}
render() {
const {tours}=this.state
return (
<section className="toulist">
{tours.map(tour=>{
return <Tour key={tour.id} tour={tour} />;
})}
</section>
)
}
}
const {id,city}=this.props.tour