import {NavLink} from 'react-router-dom';
<li>
<NavLink to="/" activeClassName="active">
<u>Главная</u>
</NavLink>
</li>
<li>
<NavLink to="/about" activeClassName="active">
<u>О нас</u>
</NavLink>
</li>
const str = 'abcde'
function reverseString(str) {
let tempString = ''
for(let j = str.length - 1; j >= 0; j--){
tempString += str[j]
}
return tempString
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
const str = 'abcde'
function reverseString(str) {
return str.split('').reverse().join('')
}
console.log('str:', str)
console.log('reverse:', reverseString(str))
npm init react-app my-app
npm run eject
npm run start
npm run build
const duration = '30';
const startTime = moment().format('DD-MM-YYYY') // 26-10-2018
const endTime = moment().add(duration, 'days').format('DD-MM-YYYY') // 26-11-2018
const duration = {
years: '1',
months: '5',
days: '30'
};
const startTime = moment().format('DD-MM-YYYY') // 26-10-2018
const endTime = moment().add(duration).format('DD-MM-YYYY') // примерно 25-05-2020
class Container extends React.Component {
state = {
showModal: false
}
handleModal = () => {
this.setState({showModal: !this.state.showModal});
}
render() {
return (
<Fragment>
{ this.state.showModal && <MyModal handleModal={this.handleModal}/> }
<button onClick={this.handleModal}> Show modal </button>
</Fragment>
)
}
axios({
method:'get',
url:'http://bit.ly/2mTM3nY',
responseType:'stream'
})
.then(function (response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
.getElementsByClassName
- всегда возвращает коллекцию, даже если элемент один. var list = document.getElementsByClassName('list')[0];
var item = list.getElementsByClassName('item')[3];
let elem = document.querySelector('.element[data-attr=this-element]')
let [elem] = [...document.getElementsByClassName('element')]
.filter((item) => { return item.getAttribute('data-attr') === 'this-element' })
let [elem] = [...document.getElementsByClassName('element')]
.filter((item) => { return item.dataset.attr === 'this-element' })
я не силен в typescript
let items = [1];
add = (i) => {
if (i <= 10) {
setTimeout(() => addItem(i), 3000)
}
}
addItem = (item) => {
items = [...items, item]
//items = items.concat([item])
//items.push(item)
}
//проверить
test = () => {
console.log(items)
add(5)
add(6)
add(999)
console.log(items)
setTimeout(() => console.log(items), 3500)
}
test()
//Console:
//[1]
//[1]
//[1, 5, 6]