functional component react
JavaScript
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}const component = props => {
console.log("This is a functional Component that uses props");
}function Welcome(props) { return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome name="Sara" />;ReactDOM.render(
element,
document.getElementById('root')
);class MyComponent extends React.Component{
constructor(props){
super(props);
};
render(){
return(
<div>
<h1>
My First React Component!
</h1>
</div>
);
}
};
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>
)
}
}
//------------------------------------------------------
import React, { Component } from 'react';
import './Tour.scss';
export default class Tour extends Component {
state={
showinfo:false,
name:""
}
handleInfo=()=>{
this.setState({
showinfo:!this.state.showinfo,
name:"kumar"
})
}
render() {
const {id,city,name,info,img}=this.props.tour
return (
<div className="grid">
<article className="tour">
<div className="img-container">
<img
src={img}></img>
<span className="close-btn">
<i class="fa fa-window-close"></i>
</span>
</div>
<div className="info">
<div className="tour-info">
<h3>{name}</h3>
<h4>{city}</h4>
<h5>info{""}
<span class="fa fa-caret-square-down" onClick={this.handleInfo}></span></h5>
</div>
{this.state.showinfo && <p>{info}{this.state.name}</p>}
</div>
</article>
</div>
)
}
}function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
function App() {
return (
<div>
<Welcome name="Sara" /> <Welcome name="Cahal" /> <Welcome name="Edite" /> </div>
);
}
ReactDOM.render(
<App />,
document.getElementById('root')
);
Also in JavaScript:
- Title
- how to add a class to html using javascript
- Category
- JavaScript
- Title
- covid folium
- Category
- JavaScript
- Title
- get data from json using jquery
- Category
- JavaScript
- Title
- angular run with proxy
- Category
- JavaScript
- Title
- how to get element from arraylist react
- Category
- JavaScript
- Title
- drupal 8 check if current page is node
- Category
- JavaScript
- Title
- javascript button onclick
- Category
- JavaScript
- Title
- express route parameters
- Category
- JavaScript
- Title
- for function js
- Category
- JavaScript
- Title
- add dev dependency yarn
- Category
- JavaScript
- Title
- get url react
- Category
- JavaScript
- Title
- boucle foreach js
- Category
- JavaScript
- Title
- change bloodhound remote dynamically
- Category
- JavaScript
- Title
- chart.js data from mysql vanila javscript
- Category
- JavaScript
- Title
- How to check whether a string contains a substring in JavaScript?
- Category
- JavaScript
- Title
- Function used to reload the portion of a page using javascript
- Category
- JavaScript
- Title
- How can I upload files asynchronously
- Category
- JavaScript
- Title
- how to use a fixed time zone in nodejs
- Category
- JavaScript
- Title
- how to access child img src in jquery
- Category
- JavaScript
- Title
- firestore batch add array
- Category
- JavaScript
- Title
- javascript change attribute
- Category
- JavaScript
- Title
- how to add javascript to html
- Category
- JavaScript
- Title
- get page resolution jquery
- Category
- JavaScript
- Title
- insert json into sql
- Category
- JavaScript
- Title
- error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class.
- Category
- JavaScript
- Title
- how to load localt ext file in js
- Category
- JavaScript
- Title
- array find method javascript
- Category
- JavaScript
- Title
- check unique object in array javascript site:stackoverflow.com
- Category
- JavaScript
- Title
- bind jquery trough name
- Category
- JavaScript
- Title
- add custom marker in react-mapbox-gl
- Category
- JavaScript
- Title
- javascript array stackoverflow
- Category
- JavaScript
- Title
- define maxmum size of schema field in nodejs
- Category
- JavaScript
- Title
- create object javascript
- Category
- JavaScript
- Title
- Alert.alert closing expo
- Category
- JavaScript
- Title
- append new element for each value in array d3.js
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- body-parser node
- Category
- JavaScript
- Title
- check if string is datestring javascript
- Category
- JavaScript
- Title
- how to make a text editor in html
- Category
- JavaScript
- Title
- how to get the last element in javascript
- Category
- JavaScript
- Title
- angular 8 to 9
- Category
- JavaScript
- Title
- find substring in string javascript
- Category
- JavaScript
- Title
- how to get the height of window in javascript
- Category
- JavaScript
- Title
- axios delete request payload
- Category
- JavaScript
- Title
- angular list contains property
- Category
- JavaScript
- Title
- click doesn't work on ajax loaded data
- Category
- JavaScript
- Title
- array spread operator in javascript
- Category
- JavaScript
- Title
- git empty commit
- Category
- JavaScript
- Title
- autocomplete typeahead ajax
- Category
- JavaScript
- Title
- hasownproperty.call
- Category
- JavaScript
- Title
- create table jquery
- Category
- JavaScript
- Title
- how to write a program that displays a message “It’s Fun day” if it's Saturday or Sunday today in javascript
- Category
- JavaScript
- Title
- array to comma separated list js
- Category
- JavaScript
- Title
- get caret index js
- Category
- JavaScript
- Title
- check if javascript function is true
- Category
- JavaScript
- Title
- how to get data from localstorage in javascript
- Category
- JavaScript
- Title
- how to deploy react app in tomcat server
- Category
- JavaScript
- Title
- add jquery to wordpress
- Category
- JavaScript
- Title
- .join javascript
- Category
- JavaScript
- Title
- javascript canvas reset transform
- Category
- JavaScript
- Title
- include gif in react
- Category
- JavaScript
- Title
- for each python json
- Category
- JavaScript
- Title
- javascript check string lenght
- Category
- JavaScript
- Title
- how to get an absolute in js
- Category
- JavaScript
- Title
- como utilizar jquery
- Category
- JavaScript
- Title
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project electronicbookshop: Compilation failure
- Category
- JavaScript
- Title
- create a form and submit it dynamically jquery
- Category
- JavaScript
- Title
- jason rpc reactjs
- Category
- JavaScript
- Title
- in javascript check is is an array or not
- Category
- JavaScript
- Title
- How to copy text from a div to clipboard
- Category
- JavaScript
- Title
- dynamic for loop react
- Category
- JavaScript
- Title
- how to use chart js in vue js
- Category
- JavaScript
- Title
- how to copy to clipboard in react js
- Category
- JavaScript
- Title
- how to use custom stylesheets express node
- Category
- JavaScript
- Title
- get url params angular
- Category
- JavaScript
- Title
- change js to json
- Category
- JavaScript
- Title
- how to auto refresh page in javascript
- Category
- JavaScript
- Title
- adding cors in angular
- Category
- JavaScript
- Title
- check if number appears odd number of times in array javascript
- Category
- JavaScript
- Title
- add a route to a buttoin in angular
- Category
- JavaScript
- Title
- angular for loop
- Category
- JavaScript
- Title
- foreach over array javascript
- Category
- JavaScript
- Title
- get value onChange from mat-select angular
- Category
- JavaScript
- Title
- how to find out what a string ends with in javascript
- Category
- JavaScript
- Title
- how to test fetch
- Category
- JavaScript
- Title
- array map javascript mozilla
- Category
- JavaScript
- Title
- get current directory vbscript
- Category
- JavaScript
- Title
- 2gis nuxt
- Category
- JavaScript
- Title
- add new items in a select input using js
- Category
- JavaScript
- Title
- how to link javascript to html
- Category
- JavaScript
- Title
- Cannot set property 'innerHTML' of null
- Category
- JavaScript
- Title
- how to use react memo hooks
- Category
- JavaScript
- Title
- drupal 8 node has field
- Category
- JavaScript
- Title
- how to send an alert in javascript
- Category
- JavaScript
- Title
- getelementbyid
- Category
- JavaScript
- Title
- button click function in js
- Category
- JavaScript
- Title
- how to mass comment in p5
- Category
- JavaScript
- Title
- how to Fetch the index of table row using jquery
- Category
- JavaScript
- Title
- How to uninstall npm modules in node js?
- Category
- JavaScript
- Title
- how to check if window size of browser s changed javascript
- Category
- JavaScript