Skip to content

Instantly share code, notes, and snippets.

View john1jan's full-sized avatar

John Francis john1jan

View GitHub Profile
@john1jan
john1jan / ChildBinding.js
Last active March 20, 2017 16:31
ChildBinding while method invocation
class ChildComponent extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'I am Child ' };
}
render() {
return <div>
<p> Child Component</p>
<input type="button" value="Print From Child Bind" onClick={this.props.printParent.bind(this, "Mars")} />
@john1jan
john1jan / ChildConstructor.js
Created March 20, 2017 16:22
Child Contructor Binding
class ChildComponent extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'I am Child ' };
this.printChild = this.printChild.bind(this);
}
render() {
return <div>
<p> Child Component</p>
@john1jan
john1jan / PChildComponent.js
Last active March 21, 2017 12:52
Passing Params Child Component
class ChildComponent extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'I am Child ' };
}
render() {
return <div>
<p> Child Component</p>
<input type="button" value="Print From Child" onClick={this.props.printParent("Mars")} />
@john1jan
john1jan / Parent.js
Last active March 20, 2017 15:57
Parent Child
class Parent extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'I am parent ' };
this.printParent = this.printParent.bind(this);
}
render() {
return <div>
@john1jan
john1jan / ParamConstBinding.js
Created March 20, 2017 15:27
ParamConstBinding
class App extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'Hello ' };
this.print= this.print.bind(this);
}
render() {
return <div>
@john1jan
john1jan / ConstructorBindingSample.js
Created March 20, 2017 15:07
ConstructorBindingSample
class App extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'Hello World' };
this.print = this.print.bind(this);
}
render() {
return <div>
@john1jan
john1jan / ES6Sample.js
Created March 20, 2017 14:51
ES6Sample
class App extends React.Component {
constructor(props) {
super(props);
this.state = { message: 'Hello World' };
}
render() {
return <div>
<p> Binding Revealed</p>
@john1jan
john1jan / ArrowSample.js
Created March 20, 2017 13:22
ArrowSample
var Sample = React.createClass({
printMars(message) {
console.log("Hello " + message);
},
render() {
return (
<div>
@john1jan
john1jan / BindingSample2.js
Last active March 20, 2017 13:11
BindingSample2
var Sample = React.createClass({
getInitialState() {
return {
message: "Hello World"
}
},
print() {
console.log(this.state.message);
@john1jan
john1jan / BindingSample1.js
Created March 20, 2017 12:47
Binding Explained
var Sample1 = React.createClass({
print(message) {
console.log("Hello " + message);
},
render() {
return (
<input type="button" value="Print" onClick={this.print("Mars")} />
);