Skip to content
TheChatArchiveThe Chat Archive
Mistralmistral-medium-2505· Mistral AIHugging Face LMArena Human Preference 140K

give me cde for a smple react app

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-5-sonnet-20241022’s answer.
  1. User

    give me cde for a smple react app

  2. Mistral Assistant

    Here's a simple React app that displays a counter with increment/decrement buttons. This example includes everything you need to get started:

    1. Set Up the Project

    First, create a new React app using Create React App (or your preferred method):

    npx create-react-app simple-counter-app
    cd simple-counter-app
    

    2. Replace src/App.js with this code:

    import React, { useState } from 'react';
    import './App.css';
    
    function App() {
      const [count, setCount] = useState(0);
    
      const increment = () => setCount(count + 1);
      const decrement = () => setCount(count - 1);
      const reset = () => setCount(0);
    
      return (
        <div className="App">
          <header className="App-header">
            <h1>Simple Counter App</h1>
            <div className="counter-display">
              <h2>{count}</h2>
            </div>
            <div className="button-group">
              <button onClick={decrement} className="counter-button">-</button>
              <button onClick={reset} className="counter-button reset">Reset</button>
              <button onClick={increment} className="counter-button">+</button>
            </div>
          </header>
        </div>
      );
    }
    
    export default App;
    

    3. Replace src/App.css with this styling:

    .App {
      text-align: center;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: calc(10px + 2vmin);
      color: white;
      background-color: #282c34;
    }
    
    .App-header {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 2rem;
    }
    
    .counter-display {
      padding: 2rem;
      background-color: #61dafb;
      border-radius: 10px;
      width: 200px;
      color: #282c34;
      font-size: 3rem;
    }
    
    .button-group {
      display: flex;
      gap: 1rem;
    }
    
    .counter-button {
      padding: 1rem 2rem;
      font-size: 1.5rem;
      background-color: #61dafb;
      color: #282c34;
      border: none;
      border-radius: 5px;
      cursor: pointer;
      transition: background-color 0.3s;
    }
    
    .counter-button:hover {
      background-color: #21a1c4;
    }
    
    .counter-button.reset {
      background-color: #ff6b6b;
    }
    
    .counter-button.reset:hover {
      background-color: #e05656;
    }
    

    4. Run the App

    Start the development server:

    npm start
    

    This will open your app in the browser at http://localhost:3000. You should see:

    • A title "Simple Counter App"
    • A counter display showing the current count
    • Three buttons: "-" to decrement, "Reset" to set to 0, and "+" to increment

    Key Concepts Demonstrated:

    1. React Hooks: Using useState to manage component state
    2. Event Handling: Button click handlers
    3. Component Structure: Basic React component structure
    4. Styling: CSS for a clean, responsive layout
    5. JSX Syntax: Combining HTML-like syntax with JavaScript

    You can expand this by adding features like:

    • Local storage to persist the count
    • Animation effects
    • More complex state management
    • Additional styling or themes

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.