Introduction
React is designed to build dynamic, interactive user interfaces and at the heart of that dynamism are dynamic values. When do you need dynamic values? great question, say you're handling user input, fetching data, or responding to events like button clicks, React makes it easy to update the UI in real-time. In this article, we’ll walk through how to render and manage dynamic values using core React concepts like JSX expressions, state, props, event handlers, and more.
Table of Contents
- File Structure
- What Are Dynamic Values in React?
- Rendering Dynamic Variables
- JSX Expressions
- State: React’s Way to Handle Change
- Event Handlers + State
- Using Props for Reusability
- Conditional Rendering
- Lists & .map()
- Bonus: String Interpolation, Template Literals
- Conclusion
1. File Structure
📁 src/
├── 📁 components/
│ └── 📄 ProfileCard.js
├── 📄 App.js
└── 📄 index.js
React Norms Covered
- Component file names should use PascalCase (e.g., ProfileCard.js)
- Component functions should start with capital letters (e.g., function ProfileCard)
2. What Are Dynamic Values in React?
Dynamic values are the parts of your UI that change over time like user input, fetched data, or button clicks. React allows you to inject those values directly into your UI using JSX expressions, state, and props.
3. Rendering Dynamic Variables
Anything inside { } in JSX is treated as JavaScript this is how you "inject" values into your HTML-like code.
export default function ProfileCard(){
const name = "React";
return <h1>Hello, {name}!</h1>;
}

4. JSX Expressions
export default function ProfileCard(){
const name = "React User";
const profileCompletion = 85; // out of 100
return (
<div className="profile-card">
<h2>{name}</h2>
<p>
Profile: {profileCompletion >= 80 ? "Complete ✅" : "Incomplete ❌"}
</p>
</div>
);
}

You can also do,
Sure! Here's the list continued in your style.
You can do,
- Math: {score + 10} // Adds 10 to the score value.
- Ternaries: {isLoggedIn ? "Welcome" : "Please log in"} // If isLoggedIn is true, show "Welcome", otherwise show "Please log in".
- Logical AND: {isAdmin && <button>Delete</button>} // If isAdmin is true, show the "Delete" button. If false, nothing is rendered.
- Function calls: {formatDate(new Date())} // Calls the formatDate function with the current date and returns the formatted string.
- Mapping arrays: {items.map(item => <li>{item}</li>)} // Loops through items array and renders each item inside an <li> element.
- String interpolation: {"Hello, " + name} // Uses string concatenation to combine a string and variable, like Hello, React.
- Object property access: {user.email} // Accesses and displays the email property of the user object.
- String methods: {username.toUpperCase()} // Converts username to uppercase.
- Nullish coalescing: {user.bio ?? "No bio"} // If user.bio is null or undefined, show "No bio". Otherwise, show user.bio.
- Optional chaining: {user.address?.city} // Safely accesses city under address, and returns undefined if address is null or undefined.
- Array length: {messages.length} // Returns the length of the messages array.
- Date formatting: {new Date().toLocaleDateString()} // Formats the current date using the browser's default locale settings.
5. State: React’s Way to Handle Change
React’s useState lets components remember values and re-render when they change. Meaning, when you click the button, count updates, and React re-renders the component with the new value.



Join the conversation! Your thoughts help the community grow.