[英]How to properly alert certain variable lastname and firstname in reactjs
I am working with airtable.com database.我正在使用 airtable.com 数据库。 Here I am trying to display of a record of a particular table where table id is 101.
在这里,我试图显示表 id 为 101 的特定表的记录。
Everything works fine as records are displayed.显示记录时一切正常。
Here is my issue: I need to alert lastname and firstname of that record so I have added:这是我的问题:我需要提醒该记录的姓氏和名字,所以我添加了:
alert(record.lastname);
alert(record.firstname);
but nothing is alerted.但没有任何警报。
Here is the code that successfully displayed records:下面是成功显示记录的代码:
function RecordList1() {
const base = useBase();
const table = base.getTableByNameIfExists('my-tablename-here');
// grab all the records from that table
const records = useRecords(table);
const recordSearch = records.filter(record => record.id == '101');
//alert(record.lastname);
//alert(record.firstname);
// render a list of records:
return (
<ul>
{recordSearch.map(record => {
return <li key={record.id}>{record.id} -- {record.lastname} ---- {record.firstname}</li>
})}
</ul>
);
}
filter
function returns an array so alert line should be like this. filter
function 返回一个数组,所以警报行应该是这样的。 alert(recordSearch[0].lastname)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.