interface Name {
name: string;
}
interface LastName {
lastName: string;
family: string[];
}
function Component(props: Name): React.ReactElement;
function Component(props: LastName): React.ReactElement;
function Component(props: Name | LastName): React.ReactElement {
if ('family' in props) {
return <b>{props.lastName}</b>
} else {
return <b>{props.name}</b>
}
}
interface IAnimal {
name: string;
say: () => string;
}
abstract class Animal implements IAnimal {
name: string;
constructor(name: string) {
this.name = name;
}
say() {
return `${this.name} says ${this.phrase}`;
}
protected abstract phrase: string;
}
class Cat extends Animal {
protected get phrase() { return 'm'; }
}
const c = new Cat('q');
console.log(c.say());
const bounds: TRange = [32400, 54000];
// getSpaceRanges(bounds, [
// [35000, 37000],
// [36000, 54000],
// ])
export default const MyItem = React.memo(({ item, setNewItemData }) => {
....
});
let [items, setItems] = useState(myData);
const setNewItemData = useCallback((itemId, data) => {
setItems((items) => {
return items.map(item => {
if (item.id !== itemId) {
return item;
}
return {...item, data}
});
});
}, [setItems]);
const [search,setSearch] = useState(null);
const [search,setSearch] = useState('');