Skip to content

Instantly share code, notes, and snippets.

View codingnninja's full-sized avatar
💭
Working to change the world

Ayobami Ogundiran codingnninja

💭
Working to change the world
View GitHub Profile
class Vote extends React.Component {
constructor(){
super();
this.state = {
message: "Click on an image to vote"
};
this.voteForBuhari = this.voteForBuhari.bind(this);
this.voteForFela = this.voteForFela.bind(this);
this.voteForSowore = this.voteForSowore.bind(this);
}
'use strict';
const e = React.createElement;
class FollowButton extends React.Component {
constructor(props) {
super(props);
this.state = { follow: false };
}
render() {
if (this.state.follow) {
return 'You are following this.';
const e = React.createElement;
class FollowButton extends React.Component {
constructor(props) {
super(pros);
this.state = { follow: false };
}
render() {
if (this.state.follow) {
return 'You are following this.';
}
function Dialog(props) {
return (
<div className="dialog">
<h1 className="Dialog-title">
{props.title}
</h1>
<p className="Dialog-message">
{props.message}
</p>
{props.children}
@codingnninja
codingnninja / Dialog.js
Created March 11, 2019 12:42
Dialog (JXS)
<Dialog title="Sign up now" message="Get superpowers for free">
<input name={this.state.login} onChange={this.handleLogin} />
</Dialog>
@codingnninja
codingnninja / signup.js
Last active March 11, 2019 13:01
Signup ( A class component)
class SignUp extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleSignUp = this.handleSignUp.bind(this);
this.state = {username: ''};
}
render() {
return (
@codingnninja
codingnninja / login.js
Created March 11, 2019 13:07
Login (A class component)
class Login extends React.Component {
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleLogIn = this.handleLogIn.bind(this);
this.state = {username: ''};
}
render() {
return (
@codingnninja
codingnninja / App.js
Last active August 4, 2019 13:30
React state setup for FoodReca
import React from 'react';
class App extends React.Component {
constructor() {
super();
this.state = {
id: null,
userId: 1,
food: '',
@codingnninja
codingnninja / FoodItemList.js
Created August 4, 2019 15:29
Food item list
import React from 'react';
const FoodItemList = (props) => {
return (
<table className="table table-bordered">
<thead>
<tr>
<th>Id</th>
<th>Food</th>
<th>Cost</th>
@codingnninja
codingnninja / EditFoodItemForm.js
Last active August 5, 2019 17:00
Edit food item
import React from 'react'
const EditFoodItemForm = props => {
return (
<form className="col-sm-4">
<div>
<div>
<label className="text-white">Food name</label>
<input type="text" name="food" value={props.food} onChange={ props.handleInputChange}/>
</div>