Skip to content

Instantly share code, notes, and snippets.

View rajat1saxena's full-sized avatar
😃
Building an open-source LMS

Rajat Saxena rajat1saxena

😃
Building an open-source LMS
View GitHub Profile
<!-- If the "props" object is: {name: 'rajat'} -->
<div>
rajat
</div>
<Hello name='rajat' age={26}/>
class Counter extends React.Component {
// this method should be present in your component
render() {
return (
<div>
{this.props.name}
</div>
);
}
}
class Counter extends React.Component {
constructor() {
super();
// define the internal state of the component
this.state = {name: 'rajat'}
}
render() {
function Hello(props) {
return <div>{props.name}</div>
}
ReactDOM.render(<Hello name="rajat"/>, document.getElementById('root'));
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {count: this.props.start || 0}
// the following bindings are necessary to make `this` work in the callback
this.inc = this.inc.bind(this);
this.dec = this.dec.bind(this);
}
<button disabled={true}>Press me!</button>
<button disabled={true}>Press me {3+1} times!</button>;
<div className='container'><Hello /></div>
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.status(200).send({
data: 'It works!'
})
})
app.listen(3000)