- bugless.ir [at] yahoo [dot] com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/')) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body{ | |
| font-family: 'Tahoma'; | |
| h1{ | |
| color: orange; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gulp = require('gulp'), | |
| sass = require('gulp-sass'); | |
| gulp.task('sass', function() { | |
| return gulp.src('style/style.scss') | |
| .pipe(sass()) | |
| .pipe(gulp.dest('style/')) | |
| }); |