Casts from the community

The latest and greatest from our community!
    import React from 'react';
    import ReactDOM from 'react-dom';
    
    import defaultSlides from './defaultSlides';
    
    const Slider = ({ slides }) => {
      // Create a curr state indicating what's the current slide's index
      const [curr, setCurr] = React.useState(0);
      const { length } = slides;
      
      const goToNext = () => {
        // Check if we've reached the final slide in the array
        // If so, go back to 0, else curr + 1
        setCurr(curr === length - 1 ? 0 : curr + 1);
    <html>
        <head>
            <link rel="stylesheet" href="index.css">
        </head>
        <body>
            <div id="app">
            <p>Enter your name: </p>
            <input v-model="name"/>
            <button @click="greeting='Hello ' + name">Show Greeting</button>
            <p>{{greeting}}</p>
            </div>
            <script src="index.pack.js"></script>
        </body>
    </html>
    // The prime factors of 13195 are 5, 7, 13 and 29.
    
    // What is the largest prime factor of the given number?
    
    function largestPrimeFactor(number) {
      let largestPrime = 0;
      
      const isPrime = num => {
          for (let i = 2; i <= Math.sqrt(num); i++) {
              if (num % i === 0) {
                  return false;
              }
          }
          return num !== 0 && num !== 1;
    import Vue from 'vue';
    import Vuex from 'vuex';
    
    Vue.use(Vuex);
    
    const store = new Vuex.Store({
        state: {
            count: 0
        },
        mutations: {
            increment (state) {
                state.count++
            }
        }
    import React, {useState, useCallback} from 'react'
    import ReactDOM from 'react-dom'
    import Color from './Color'
    import Letter from './Letter'
    import randomColor from 'randomcolor'
    import randomLetter from 'random-letter'
    
    // Memoization:
    // returning the cached result of expensive operations
    // if the inputs have not changed
    
    // useCallback
    // Pass an inline callback and an array of inputs.
    // useCallback will return a memoized version of the callback that o
    import React from 'react';
    import ReactDOM from 'react-dom';
    
    //Class
    class Main extends React.Component {
      render() {
        return (
          <div>
            <h1>Hello world!</h1>
            <Counter/>
          </div>
        );
      }
    }
    var app = new Vue({ 
        el: '#app',
        data: {
            message: 'Hello Vue!'
        }
    });