Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

props in classes

// Component.js

import React from 'react';

export default class MyClassComponent extends React.Component {
    render() {
        return (<div>
            {/* В классовом компоненте props доступны через this */}
            Hello Class, {this.props.name}!
        </div>);
    }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: close jquery 
Javascript :: how to make a vertical array js 
Javascript :: how to change string to array in javascript 
Javascript :: greater than or equal to javascript 
Javascript :: cheapest node js hosting 
Javascript :: process.env type 
Javascript :: calling anonymous function while declaring it 
Javascript :: javascript fuzzy search 
Javascript :: mobile nav react npm 
Javascript :: empty object is falsy 
Javascript :: angular material moduel 
Javascript :: how to use axios 
Javascript :: promises chaining 
Javascript :: find key in nested json object 
Javascript :: label animation css 
Javascript :: case switch javascript 
Javascript :: javascript custom modal 
Javascript :: nodejs get cpu count 
Javascript :: angular $http abort request 
Javascript :: js slice 
Javascript :: form- text area react 
Javascript :: javascript get response payload 
Javascript :: javascript string compare 
Javascript :: react native measure 
Javascript :: how to target two id using jquery 
Javascript :: js Arrays indexOf 
Javascript :: random picture position in react 
Javascript :: create canvas p5 
Javascript :: swagger on expres node app 
Javascript :: create random password 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =