JavaScript
30
Вклад в тег
class Component {
constructor(props) {
this.props = props;
}
}
import React, { Component } from 'react';
import { Collapse, Button, CardBody, Card } from 'reactstrap';
class Example extends Component {
state = {
collapse: false
};
toggle = () => {
this.setState(state => ({ collapse: !state.collapse }));
}
render() {
return (
<div>
<Button color="primary" onClick={this.toggle} style={{ marginBottom: '1rem' }}>Toggle</Button>
<Collapse isOpen={this.state.collapse}>
<Card>
<CardBody>
Anim pariatur cliche reprehenderit,
enim eiusmod high life accusamus terry richardson ad squid. Nihil
anim keffiyeh helvetica, craft beer labore wes anderson cred
nesciunt sapiente ea proident.
</CardBody>
</Card>
</Collapse>
</div>
);
}
}
export default Example;
function fearNotLetter(str) {
const letters = str.split("");
const letter = letters.reduce((acc, letter, index) => {
if (acc !== undefined) return acc;
const prevLetterCode = (letters[index - 1] || letter).charCodeAt();
if (letter.charCodeAt() - prevLetterCode > 1) return String.fromCharCode(prevLetterCode + 1)
return undefined;
}, undefined);
return letter;
}
fearNotLetter("abce");
//d
import debounce from "lodash/debounce";
const TIME_OUT = 1000;
const handleSearch = debounce(({ target: { value } = {} }) => {
//что-то делаем
}, TIME_OUT)
$yourInput.addEventListener("input", handleSearch, false);