Skip to content

Instantly share code, notes, and snippets.

View buglessir's full-sized avatar

Mohammad Esmaeilzadeh buglessir

  • Iran, Tehran
View GitHub Profile
import React from 'react';
import { UserContext } from './components/User';
class Profile extends React.Component {
render() {
return (
<UserContext.Consumer>
{(user) => (
<div>
<strong>Name: <strong> {user.name}<br />
import React, { createContext } from 'react';
import Profile from './components/Profile';
const UserData = {
name: 'Mohammad Esmaeilzadeh',
title: 'Front-end Developer',
url: 'https://virgool.io/@buglessir'
};
export const UserContext = createContext();
import React, { PureComponent } from 'react';
import { render } from 'react-dom';
class App extends PureComponent {
constructor(props) {
super(props);
this.state = {
name: ''
};
this.set_name = this.set_name.bind(this);
import React, { PureComponent } from 'react';
import { render } from 'react-dom';
class App extends PureComponent {
constructor(props) {
super(props);
this.state = {
name: ''
};
this.set_name = this.set_name.bind(this);
import React, { Component } from 'react';
import { render } from 'react-dom';
class App extends Component {
constructor(props) {
super(props);
this.state = {
name: ''
};
this.set_name = this.set_name.bind(this);
function immutable(originalArray) {
// Instead of mutating/modifying the original array,
// we first make a copy of the original array
// In this way, the original array stay unchanged.
var newArray = [...originalArray];
newArray[0] = "new value";
return newArray;
}
var array = ["some value", "another value"];
function mutation(originalArray) {
// directly mutating/modifying the original array
originalArray[0] = "new value";
return originalArray;
}
var array = ["some value", "another value"];
alert("Return from mutation " + mutation(array));
alert("Array: " + array + " (original array has been altered).");
var gulp = require('gulp'),
sass = require('gulp-sass'),
cssMinify = require('gulp-clean-css');
gulp.task('sass', function() {
return gulp.src('style/style.scss')
.pipe(sass())
.pipe(cssMinify())
.pipe(gulp.dest('style/'))
});
body{
font-family: 'Tahoma';
h1{
color: orange;
}
}
var gulp = require('gulp'),
sass = require('gulp-sass');
gulp.task('sass', function() {
return gulp.src('style/style.scss')
.pipe(sass())
.pipe(gulp.dest('style/'))
});