MeetCode - Programming Platform | MeetCode - Programming Solutions Platform

ReactJS Program to Empty State Component with Explanation

ReactJS Medium Component Design 22 views
This problem helps you practice core ReactJS fundamentals in a practical way. It builds intuition around component, button, react. Let’s break it down step by step so you can implement it confidently.
Back to Questions

Problem Statement

Create an EmptyState component that shows a title, message, and an action button.

Input Format

No input.

Output Format

Render a React component.

Constraints

Use props for text and button handler.

Code Solution

This explanation is written for learning purposes and to help beginners understand the concept clearly.
import React from 'react'; export function EmptyState({ title, message, actionLabel, onAction }) { return ( <div style={{ border: '1px dashed #bbb', borderRadius: 14, padding: 16, width: 420 }}> <h2 style={{ margin: '0 0 8px 0' }}>{title}</h2> <p style={{ margin: '0 0 12px 0', color: '#555' }}>{message}</p> <button type='button' onClick={onAction} style={{ padding: '10px 14px', borderRadius: 12, border: 0, background: '#0b5', color: '#fff' }}> {actionLabel} </button> </div> ); } export default function App() { return ( <EmptyState title='No saved questions' message='Save a question on meetcode to see it here.' actionLabel='Browse topics' onAction={() => {}} /> ); }

Output Example

No sample I/O is provided for this question.

Common Mistakes

- Misreading input/output format.
- Not handling constraints and edge cases.
- Off-by-one errors in loops.
- Forgetting to reset variables between test cases (if any).

Notes & Extra Practice

Solutions (0)

No solutions submitted yet. Be the first!

Prev Next