const names = [ 'иван', 'антон' ] as const;
type Name = typeof names[number];
const fn = (name: Name) => name;
seachCityName - обычная строка
seachCityName.value
. мне ж понятно будет
interface IFormData {
firstName: string;
lastName: string;
}
const [ formData, setFormData ] = React.useState<IFormData>({
firstName: '',
lastName: '',
});
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => setFormData({
...formData,
[e.target.name]: e.target.value,
});
<CustomTextField name="firstName" value={formData.firstName} onChange={onChange} />
<CustomTextField name="lastName" value={formData.lastName} onChange={onChange} />
<!-- или -->
{Object.entries(formData).map(([ k, v ]) => (
<CustomTextField key={k} name={k} value={v} onChange={onChange} />
))}
const toCamelCase = val =>
val instanceof Array
? val.map(toCamelCase)
: val instanceof Object
? Object.fromEntries(Object
.entries(val)
.map(n => [
n[0].replace(/_+(.)/g, (m, g1) => g1.toUpperCase()),
toCamelCase(n[1]),
])
)
: val;
Я не меняю prop href
@Prop(String) href = '';
It's not supported to define eachdefault
property like@Prop() prop = 'default value'
.
return new this.constructor();
This expression is not constructable. Type 'Function' has no construct signatures
const { constructor } = Object.getPrototypeOf(this);
return new constructor();
function printInc(a: string | number): void {
switch (typeof a) {
case 'string':
console.log(a + ' plus one');
break;
case 'number':
console.log(a + 1);
break;
}
}
interface ItempElement {
x: number;
y: number;
};
interface Itemp extends Array<ItempElement> {};
v-for={weekDay in this.arWeekDays}
выдает ошибку "index is not defined"
<div>
{this.arWeekDays.map(n => <div>{n}</div>)}
</div>
saveItem = (id: string, modifiedItem: TCardItem) => {