Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <!--<script src=""></script>-->

<div id="root">




                // You have the array of quotes. Each quote has body and author.
// It would be better to use "body" key instead of "quote"
// because an object is a quote itself.
// With that you will avoid this situations:
// const { quote } = quotes[quoteIndex];
// and then when you use it - it would be something like:
//  <div>{quote.quote}</div>
// As you see <div>{quote.body}</div> would be better.
// Of course in many cases it is an API response, but when possible, try to name varibles/properties properly
const quotes = [
  {quote: 'If you cannot do great things, do small things in a great way.', author: 'Napoleon Hill'},
  {quote: 'Permanence, perseverance and persistence in spite of all obstacles, discouragements, and impossibilities: It is this, that in all things distinguishes the strong soul from the weak.', author: 'Thomas Carlyle'},
  {quote: 'The supreme art of war is to subdue the enemy without fighting.', author: 'Sun Tzu'},
  {quote: 'Keep your face always toward the sunshine - and shadows will fall behind you.', author: 'Walt Whitman'},
  {quote: 'Being entirely honest with oneself is a good exercise.', author: 'Sigmund Freud'},
  {quote: 'Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.', author: 'Samuel Beckett'},
  {quote: 'Not all those who wander are lost.', author: 'J. R. R. Tolkien'},
  {quote: 'I have not failed. I\'ve just found 10,000 ways that won\'t work.', author: 'Thomas A. Edison'},
  {quote: 'Tell me and I forget. Teach me and I remember. Involve me and I learn.', author: 'Benjamin Franklin'},
  {quote: 'A leader is one who knows the way, goes the way, and shows the way.', author: 'John C. Maxwell'},
  {quote: 'Very little is needed to make a happy life; it is all within yourself, in your way of thinking.', author: 'Marcus Aurelius'},
  {quote: 'If opportunity doesn\'t knock, build a door.', author: 'Milton Berle'},
  {quote: 'The secret of getting ahead is getting started.', author: 'Mark Twain'},
  {quote: 'Problems are not stop signs, they are guidelines.', author: 'Robert H. Schuller'},
  {quote: 'Life is not a problem to be solved, but a reality to be experienced.', author: 'Soren Kierkegaard'},
  {quote: 'Life isn\'t about finding yourself. Life is about creating yourself.', author: 'George Bernard Shaw'},
  {quote: 'The only true wisdom is in knowing you know nothing.', author: 'Socrates'},
  {quote: 'The pessimist complains about the wind; the optimist expects it to change; the realist adjusts the sails.', author: 'William Arthur Ward'},
  {quote: 'In three words I can sum up everything I\'ve learned about life: it goes on.', author: 'Robert Frost'},
  {quote: 'Blessed are the hearts that can bend; they shall never be broken.', author: 'Albert Camus'},
  {quote: 'Success is not final, failure is not fatal: it is the courage to continue that counts.', author: 'Winston Churchill'},
  {quote: 'Do not go where the path may lead, go instead where there is no path and leave a trail.', author: 'Ralph Waldo Emerson'},
  {quote: 'Do not dwell in the past, do not dream of the future, concentrate the mind on the present moment.', author: 'Buddha'},
  {quote: 'Don\'t judge each day by the harvest you reap but by the seeds that you plant.', author: 'Robert Louis Stevenson'},
  {quote: 'Find a place inside where there\'s joy, and the joy will burn out the pain.', author: 'Joseph Campbell'},
  {quote: 'Try to be a rainbow in someone\'s cloud.', author: 'Maya Angelou'},
  {quote: 'It is during our darkest moments that we must focus to see the light.', author: 'Aristotle'},
  {quote: 'Good, better, best. Never let it rest. \'Til your good is better and your better is best.', author: 'St. Jerome'},

class Card extends React.Component {
  constructor(props) {
    this.state = {
      quoteIndex: this.getRandomQuoteId(quotes)

  // You had "bind" method here. 
  // You don't need it when you use "named" methods like:

  /* someMethod = () => {
    return 'Something'
  } */

  // You will see it below
  // Also, use more descriptive names for your functions and state 
  getRandomQuote = () => {
      quoteIndex: this.getRandomQuoteId()
  // Use DRY (Dont Repeat Yourself) method
  // If you see that you can create a function to avoid code duplication -> do it
  // Less code, less bugs
  // But be carefull. You dont need to generalize everything
  getRandomQuoteId = () => {
    return  Math.floor(Math.random() * quotes.length);
  render () {
    // Check how I get the quoteIndex
    // Looks cleaner and readable.
    // Again, try to avoid variables like "result" because it is too ambiguous
    const { quoteIndex } = this.state;
    const quote = quotes[quoteIndex];
    return (
      <div id="quote-box">
        <p id="text">{quote.quote}</p>
        <p id="author">{}</p>
        <button id="new-quote" onClick={this.getRandomQuote}>New Quote</button>
        <a id="tweet-quote" href="" target="_blank">Tweet Quote</a>

ReactDOM.render(<Card />, document.getElementById('root'));