Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react props

function Welcome(props) {
  return <h1>Hello, {props.name}</h1>;
}

function App() {
  return (
    <div>
      <Welcome name="Sara" />
      <Welcome name="Cahal" />
      <Welcome name="Edite" />
    </div>
  );
}
Comment

props in class react

class MouseTracker extends React.Component {
  constructor(props) {
    super(props);
    this.handleMouseMove = this.handleMouseMove.bind(this);
    this.state = { x: 0, y: 0 };
  }

  handleMouseMove(event) {
    this.setState({
      x: event.clientX,
      y: event.clientY
    });
  }

  render() {
    return (
      <div style={{ height: '100vh' }} onMouseMove={this.handleMouseMove}>
        <h1>Move the mouse around!</h1>
        <p>The current mouse position is ({this.state.x}, {this.state.y})</p>
      </div>
    );
  }
}
Comment

React js props

function App() {
  return (
    <div className="App">
      <NewComponent name="Ariful Islam Adil" profession="Web-Developer"></NewComponent>
    </div>
  );
}

function NewComponent(props) {
  return (
    <div className="test-class">
      <h1>Name: {props.name}</h1>
      <h3>Profession: {props.profession}</h3>
    </div>
  )
}
export default App;
Comment

Props example in react

const Banner = props => {
  const name = props.name
  return <div>Hello {name}</div>
}

function App() {
  return (
    <div>
      <Banner name="Ranjeet" />
    </div>
  )
}

export default App
Comment

react props

function App() {
  return <User name="John Doe" />
}

function User(props) {
  return <h1>Hello, {props.name}</h1>; // Hello, John Doe!
}
Comment

props

class Checkbox extends React.Component {
  constructor(props) {
    super(props);
    this.state = { isOn: true };
  }
  // ...
}
Comment

React props

function Application() {
  const userName = "John Smith";
  return <UserInfo userName={userName} />;
}
function UserInfo({ userName }) {
  return <span>{userName}</span>;
}
Comment

Using Props With React: With Props


function App() {

return(
<>

<Abc/>
<Abc x="xxxxx"/>
    </>
  );
}

export default App;


function Abc(props)
{
return (<>{props.x?<b>ffffff</b>:<i>gggggg</i>}</>)
}
/*Abc depends on the value of the x prop*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: react class names 
Javascript :: add value to object 
Javascript :: react hooks useeffect 
Javascript :: usereducer react 
Javascript :: timer js 
Javascript :: class component params in react 
Javascript :: . is not recognized as an internal command npm run 
Javascript :: status discored jks 
Javascript :: javascript factorial stack 
Javascript :: Everything Be True 
Javascript :: date and month are swapping in angular 
Javascript :: typeahead bootstrap 4 add multiple values 
Javascript :: db.each store rowa 
Javascript :: eslint-disable-next-line multiple 
Javascript :: jest visit a page 
Javascript :: all navigator CPU option in javascript 
Javascript :: coindeskapi ethereum 
Javascript :: how to acces db knex 
Javascript :: servers for node js 
Javascript :: js browse file 
Javascript :: javascript relational operators 
Javascript :: in which table our redux option values are save 
Javascript :: bad site theme 
Javascript :: react state scope 
Javascript :: react native bordered image drop with shadow fix 
Javascript :: bookshelfjs npm 
Javascript :: How can I display an image and text from an array on a webpage? Ask Question 
Javascript :: set drawingmode javascript 
Javascript :: Angular watching for changes in $http.pendingRequests from directive 
Javascript :: cypress graphql request example 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =