>

CODEMASTERYLAB

IDE PLATFORM
CoursesCommunity BlogsKnowledge GraphQuizzesInterview Prep

Sign in to track progress & earn XP

Sign In Create Account
>
Code Mastery Lab

Code Mastery Lab

Sign In

The React Mindset — Why UI as a Function Changes Everything

Question 1 / 1

0:00
Core
Medium

Consider the following two code snippets:

// Snippet A
const btn = document.getElementById('submit-btn')
btn.disabled = true
btn.textContent = 'Saving...'
fetch('/api/save', { method: 'POST', body: data })
  .then(() => {
    btn.disabled = false
    btn.textContent = 'Save'
  })
// Snippet B
function SaveButton({ isSaving }) {
  return (
    <button disabled={isSaving}>
      {isSaving ? 'Saving...' : 'Save'}
    </button>
  )
}

Which statement best explains the fundamental difference between these two approaches?