.class {
color: red;
transform: translateY(-100%);
transition: all 1s;
}
.class:hover {
color: blue;
transform: translateY(-50%);
}
export const renderNotes = (user , users) => dispatch => {
Object.keys(users).forEach(async element => {
if (user === users[element].login) {
const elements = await fire.database().ref('users/' + element + '/notes/');
return dispatch({
type: RENDER_NOTES,
payload: elements,
});
}
})
};
const srcArray = [ 0.134555, 0.294587, 0.570858];
const mappedArray = srcArray.map(el => (el * 100).toFixed(1) + '%');
console.log(mappedArray);
// => ["13.5%", "29.5%", "57.1%"]
submitBalance = () => {
// your stuff
};
constructor(props) {
super(props);
this.submitBalance.bind(this);
}
onClick={e => this.submitBalance(someArg, e)}
var x = 2, y = 3;
function plus1(x) {
return x + 1; // тут x это значение которое вы передали при вызове аргументом
}
plus1(y)
var square = function(x) {
return x * x; // тут тоже
};
square(plus1(y))
square(plus1(y))
square(plus1(3));
function plus1(3) {
return 3 + 1;
}
square(4);
function(4) {
return 4 * 4;
};
{
0: 10,
1: 3,
length: 2,
__proto__: Array(0)
}
var x = 10;
var y = 3;
var obj = { x: x, y: y };
var keys = Object.keys(obj);
console.log(keys);
// => [ 'x', 'y']
function Parallel(settings) {
this.parallelJobs = settings.parallelJobs;
this.results;
this.tasks = [];
this.onDone;
this.index = 0;
this.activeJobs = 0;
};
Parallel.prototype.start = function() {
this.results = Array(this.tasks.length);
for (var i = 0; i < Math.min(this.parallelJobs, this.tasks.length); i++) {
this.next();
}
}
Parallel.prototype.next = function(result) {
var index = this.index;
this.activeJobs++;
this.tasks[this.index](function(result) {
this.onResult(result, index);
}.bind(this));
this.index++;
}
Parallel.prototype.onResult = function(result, index) {
this.results[index] = result;
this.activeJobs--;
if(this.tasks[this.index]) {
this.next();
} else if (this.activeJobs === 0) {
this.onDone(this.results);
}
}
Parallel.prototype.job = function (step) {
this.tasks.push(step);
return this;
};
Parallel.prototype.done = function (onDone) {
this.onDone = onDone;
this.start();
};
function asyncRequest1(result) {
setTimeout(result, 2000, 'data');
}
function asyncRequest2(result) {
setTimeout(result, 2000, 'data 2');
}
function asyncRequest3(result) {
setTimeout(result, 2000, 'data3');
}
function asynRequest4(result) {
setTimeout(result, 2000, 'data4');
}
var runner = new Parallel({
parallelJobs: 2
});
runner.job(asyncRequest1)
.job(asyncRequest2)
.job(asyncRequest3)
.job(asyncRequest4)
.done(function (results) {
console.log(results);
});
{ tweets: tweets.data }
const reducer = (state = { tweets: tweets.data }, action) => {
switch (action.type) {
case 'DELETE': {
return {
...state,
tweets: state.tweets.filter(value => value.id !== action.id),
};
}
default:
return state;
}
};
@font-face {
font-family: 'OpenSans';
src: url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.eot");
...
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src: url("../fonts/OpenSans/OpenSansLight/OpenSansLight.eot");
...
font-weight: 300;
font-style: normal;
}
html {
font-family: 'OpenSans', sans-serif;
font-size: 14px;
}
.example-with-regular-text {
// nothing
}
.example-with-light-text {
font-weight: 300;
}
.user-logout {
border-top: 5px solid transparent;
background-clip: padding-box;
}
import { BrowserRouter, Route, Link, Switch } from 'react-router-dom';
export default class App extends Component {
render() {
return (
<BrowserRouter>
<div>
<ul>
<li><Link to='/'>Home</Link></li>
<li><Link to='/about'>About</Link></li>
<li><Link to='/contact'>Contact</Link></li>
</ul>
<hr/>
<Switch>
<Route exact path='/' component={Home}/>
<Route path='/about' component={About}/>
<Route path='/contact' component={Contact}/>
<Route path='/test/:id' component={HomePage}/>
</Switch>
</div>
</BrowserRouter>
);
}
}
export default class Home extends Component{
render(){
return(
<div>
<h1>Home</h1>
<div>
<ul>
<li><Link to='/test/1'>Фото на документы</Link></li>
<li><Link to='/test/2'>Принтер</Link></li>
<li><Link to='/test/3'>Печать на документы</Link></li>
</ul>
</div>
</div>
);
}
}
webpack -p
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new webpack.optimize.UglifyJsPlugin({
// options
}),
plugins: [
new webpack.EnvironmentPlugin(['NODE_ENV']),
new webpack.optimize.UglifyJsPlugin({
// options
}),
],
new webpack.EnvironmentPlugin(['NODE_ENV']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
GET 'api/images?limit=20&page=1'
{
data: [...],
quantity: 500,
}
GET 'api/images?limit=20&page=2'
const hasMore = page * limit < total;
25 * 20 < 500 // false
const arr1 = ['a'];
const arr2 = ['b'];
const arr3 = [...arr1, ...arr2];
const arr4 = [...arr1, 1, ...arr2, 'c'];
console.log(arr3);
// => ['a', 'b'];
console.log(arr4);
// => ['a', 1, 'b', 'c'];
const obj1 = { a: 'a', b: 'old b' };
const obj2 = { b: 'new b', c: 'c' };
const obj3 = { ...obj1, ...obj2 };
const obj4 = { ...obj2, ...obj1 };
const obj5 = { ...obj1, ...obj2, d: 'd' };
console.log(obj3);
// => { a: 'a', b: 'new b', c: 'c' };
console.log(obj4);
// => { a: 'a', b: 'old b', c: 'c' };
console.log(obj5);
// => { a: 'a', b: 'new b', c: 'c', d: 'd' };
this.props.tasks === nextProps.tasks; // true
export default function addDelete(state = initialState, action){
switch (action.type) {
case "ADD_TASK":
return {
...state,
tasks: [...state.tasks, {{id: action.id, time : action.time, task: action.task}}],
};
case "DELETE_TASK":
return {
...state,
tasks: [...state.tasks.filter(task => task.id != action.id)],
};
case "SET_ACSSES":
return {
...state,
add: !state.add,
};
default:
return state;
}
}
export default function add(time, task, id){
if(!task || !time){
return {
type: "SET_ERROR",
payload: "Error, invalid data"
};
}
return{
type: "ADD_TASK",
payload: {
id: id,
time: time,
task: task,
},
}
}
export const deleteTask = id => ({
type: 'DELETE_TASK',
payload: id,
});
export default function addDelete(state = initialState, action) {
const { type, payload } = action;
switch (type) {
case "ADD_TASK":
return {
...state,
tasks: [...state.tasks, payload],
};
case "DELETE_TASK":
return {
...state,
tasks: [...state.tasks.filter(task => task.id != payload)],
};
case "SET_ACSSES":
return {
...state,
add: !state.add,
};
default:
return state;
}
}