this.state ={url:url}
Так state обновлять нельзя.setTimeout(function() {
onReady();
}, getTimeToBoil());
setTimeout(onReady, getTimeToBoil());
var timeout = setTimeout(handler, duration);
element.addEventListener('scroll', scrollHandler);
function scrollHandler() {
clearTimeout(timeout);
element.removeEventListener('scroll', scrollHandler);
}
var timeout = setTimeout(handler, duration);
element.addEventListener('scroll', function() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
});
foo.x = foo = {n: 2};
foo.x = (foo = {n: 2});
{ n: 2 }
.let foo = {};
const bar = foo;
foo.x = (foo = {n: 2});
console.log(foo.x === undefined); // true
console.log(bar); // { x: { n: 2 } }
console.log(bar.x === foo); // true
foo.x =
- присваивание свойства конкретному объекту. На момент вызова в нашем примере это {}
.foo =
- присваивание значения самому идентификатору foo. Это может быть примитив, ссылка на объект или функцию. В нашем случае это объект { n: 2 }
. Слава богам - с этим разобрался!
Но появилась необходимость юзать библиотеку из node_modules, но с этими всякими exports, require и прочей дичью новейшего синтаксиса JS... Как это правильно сделать, в моем случае?
const nearMarkers = markers.map(obj => ({ ...obj }));
В этом случае ссылки на вложенные объекты в obj сохранятся.const nearMarkers = JSON.parse(JSON.stringify(markers));
В этом случае все вложенные объекты в obj будут клонированы.const nearMarkers = markers.map(marker => ({ ...maker, distance: someValue }));
<script>window.__INITIAL_STATE__ = json.stringify(initialState);</ script>
export = function (initialState: {} = {}) {
if (__CLIENT__) {
initialState = JSON.parse(JSON.stringify(window.__INITIAL_STATE__));
}
return createStore(combineReducers({ ...rootReducer }), initialState, enhancer);
}
...но если кладу этот файл в отдельную папку и рядом с файлом создаю файл package.json с таким содержанием...
module.exports = {
entry: './path/to/my/entry/file.js'
};
function onAjaxSucces(data) {
// do something with data
}
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар2',
ip: '300.00',
iv: 'категория2'
},
onAjaxSucces
);
$.post(
"http://www.google-analytics.com/collect",
{
v: '1',
tid: 'UA-xxxxxx-1',
cid: 'a7a364d8-0d14-4e77-b637-xxxxxxxxxx',
t: 'item',
ti: '21001',
in: 'товар2',
ip: '300.00',
iv: 'категория2'
},
function(data) {
// do something with data
}
);