I’m doing the Random Quote Machine now, and the tester is only giving me 5 correct. Before, it was giving me 10/12. I’m using create-react-app to do the project. Everything’s running good except the tweet button doesn’t get the quote when I click ‘New Quote’ button.
Here is my code.
class App extends React.Component {
constructor() {
super();
this.state = {
rQuote: ''
}
}
componentDidMount() {
this.newQuote();
}
newQuote = () => {
let randomQuote = quoteList[Math.floor(Math.random() * quoteList.length)];
this.setState({rQuote: randomQuote})
}
render() {
return (
<div id='quote-box'>
<h2>Quote of the Day!</h2>
<div id='text'>
<p><em>"{this.state.rQuote.quote}"</em></p>
<p id='author'><strong>{this.state.rQuote.author}</strong></p>
</div>
<button id="new-quote" className='myButton' onClick={this.newQuote}>New Quote</button>
<div>
<a id="tweet-quote"
Class="twitter-share-button"
href="https://twitter.com/intent/tweet"
data-text={this.state.rQuote.quote + " - " + this.state.rQuote.author}
>
</a>
</div>
</div>
)
}
}