Skip to content

Commit c3f4147

Browse files
authored
Added check for bad data (undefined tweet messages)
Accounting for bad data -- The tweets that have no messages were throwing errors in the logger and were preventing the entire list from showing. Placing the tweet texts in a string literal also helped to strip bad tweet.text inputs as well.
1 parent 23b30f0 commit c3f4147

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

5-redux-react/src/js/components/Layout.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ export default class Layout extends React.Component {
2727
return <button onClick={this.fetchTweets.bind(this)}>load tweets</button>
2828
}
2929

30-
const mappedTweets = tweets.map(tweet => <li key={tweet.id}>{tweet.text}</li>)
30+
const mappedTweets = tweets.map(tweet => {
31+
return ((typeof(tweet.text) === 'undefined')
32+
? false
33+
: <li key={tweet.id}><span>{`${tweet.text}`}</span></li>
34+
)
35+
})
3136

3237
return <div>
3338
<h1>{user.name}</h1>

0 commit comments

Comments
 (0)