Skip to content

Added check for bad data (undefined tweet messages) #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
KDCinfo authored May 27, 2017
commit c3f4147944930579f15e09a72d754057791c36ef
7 changes: 6 additions & 1 deletion 5-redux-react/src/js/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export default class Layout extends React.Component {
return <button onClick={this.fetchTweets.bind(this)}>load tweets</button>
}

const mappedTweets = tweets.map(tweet => <li key={tweet.id}>{tweet.text}</li>)
const mappedTweets = tweets.map(tweet => {
return ((typeof(tweet.text) === 'undefined')
? false
: <li key={tweet.id}><span>{`${tweet.text}`}</span></li>
)
})

return <div>
<h1>{user.name}</h1>
Expand Down