【发布时间】:2017-02-04 08:51:41
【问题描述】:
我有一个 react 应用程序,它有一个这样的组件:
import React, { Component } from 'react';
import '../css/TrelloCards.css';
class TrelloCards extends Component {
componentDidMount() {
const authenticationFailure = () => { console.log('Auth failure') };
const trello = window.Trello;
const getCards = () => {
const error = (error) => {
console.log(error);
}
const cards = (cards) => {
console.log(cards);
}
trello.get('/member/me/cards', cards, error);
}
trello.authorize({
type: 'redirect',
name: 'React Trello',
scope: {
read: 'true',
write: 'true' },
expiration: 'never',
success: getCards,
error: authenticationFailure,
response_type: 'token',
});
}
render() {
return(
<h1>Placeholder</h1>
);
}
}
export default TrelloCards;
我已经成功地在控制台记录了我的卡片,但现在我想在页面上呈现它们,我已经尝试过
render() {
return(
<ul>
{cards}
</ul>
);
}
我尝试过通过如下卡片进行映射:
cards.map(card => {
return(
<li>{card.name}</li>
);
}
但我收到未定义“卡片”的错误。总的来说,我对 React 和编程很陌生,任何帮助都将不胜感激。
【问题讨论】: