
// ❌ BROKEN COMPONENT: Contains 6 distinct ES6+ bugs!
import React, { useState } from 'react';
import { View, Text, Button, TouchableOpacity } from 'react-native';
var UserDashboard = (props) => {
// Bug 1 & Bug 2 are in the state and prop initialization
var [workouts, setWorkouts] = useState(["Morning Run", "Core Workout"]);
const { user: { profile: { name, avatar } }, unreadMessages, onRefresh } = props;
// Bug 3: Helper function using implicit return to produce an object
const createMetric = (label, value) => { label: label, value: value };
// Bug 4: Direct state mutation inside an event handler
const handleAddWorkout = () => {
workouts.push("Evening Walk");
setWorkouts(workouts);
};
const currentScore = props.score || "No score recorded";
return (
<View style={{ padding: 20 }}>
{/ Dynamic welcome header /}
<Text>"Welcome back, " + name + "!"</Text>
{/ Bug 5: Conditional UI rendering with a numeric counter /}
{unreadMessages && (
<Text>You have {unreadMessages} unread messages</Text>
)}
<Text>{`Current Score: ${currentScore}`}</Text>
{/ Workouts list /}
<View>
{workouts.map(item => (
<Text key={item}>{`• ${item}`}</Text>
))}
</View>
<Button title="Add Workout" onPress={handleAddWorkout} />
{/ Bug 6: Insecure callback trigger /}
<TouchableOpacity onPress={() => onRefresh()}>
<Text>Refresh Data</Text>
</TouchableOpacity>
</View>
);
};
export default UserDashboard;
Build a strong JavaScript foundation for React Native development by mastering six essential ES6+ concepts used in modern mobile applications.
This beginner-friendly course contains approximately 3 hours of focused video lessons, practical examples, React Native use cases, common mistakes, and technical interview insights.
You will learn how JavaScript handles variables, functions, objects, arrays, state updates, conditional rendering, and uncertain API data—giving you the confidence to read, write, and debug modern React Native code.
In this course, you will learn:
The differences between var, let, and const
Hoisting, execution phases, block scope, function scope, and the Temporal Dead Zone
How primitives, objects, and references are stored in memory
Arrow functions, implicit returns, lexical this, and common syntax mistakes
Template literals and dynamic strings in JavaScript and JSX
Object and array destructuring for props, state, defaults, renaming, and nested data
The difference between spread and rest operators
Immutable array and object updates in React Native state
Shallow copying, reference equality, and React re-rendering
Truthy and falsy values in JavaScript
Short-circuit evaluation using && and ||
Optional chaining with ?.
Nullish coalescing with ??
Safe conditional rendering in React Native
The infamous React Native 0 rendering bug
Practical patterns used in components, event handlers, lists, props, hooks, and API responses