Skip to content

Feature/lucashlaing/opensource website#174

Open
lucashlaing wants to merge 58 commits intoWill-Hsu:mainfrom
CSES-UCSD:feature/lucashlaing/OpensourceWebsite
Open

Feature/lucashlaing/opensource website#174
lucashlaing wants to merge 58 commits intoWill-Hsu:mainfrom
CSES-UCSD:feature/lucashlaing/OpensourceWebsite

Conversation

@lucashlaing
Copy link

finished open source page

kevwu27 and others added 30 commits October 2, 2024 15:49
…orOption

Removed Minor Option When Minor is Unadded Will-Hsu#167
…rdPhotos

adding board photos and remove innovate org
…eFormatting

Feature/ganeshkumar321/fe mobile formatting
…1/FE-mobileFormatting

Revert "Feature/ganeshkumar321/fe mobile formatting"
nikhilitis and others added 28 commits November 26, 2024 18:07
fixed small syntax errors (semicolons and single-quotes)
… to the center, and matched other buttons to the same style as other page
…eFormatting

fixed some frontend mobile issues
…xtUpdate

Temporarily added Shruti and Himansi as admins
…/FE-TemplateWebsite

Added Template Website for the Communities
Since the issue **always skips the letter at index 1**, and the console logs show the correct indexing logic, let's focus on **how state updates are processed inside React's reconciliation system**.

### **Key Observations:**
1. **The first letter is always correct.**
2. **The second letter is always skipped.**
3. **The rest of the letters appear correctly.**
4. **No matter what text you pass in, the second character always disappears.**

---

## **Likely Root Cause:**
### **React's  batching updates incorrectly due to async state updates.**
- The issue occurs because  **relies on **.
- React batches multiple state updates inside , which may **cause the second letter to be skipped**.

### **Why?**
- The  function schedules updates asynchronously.
- If React batches multiple updates,  may not update in time before the next iteration.
- **Since  is inside , the state might not reflect the latest changes in time for the second character.**

---

## **Final Fix: Use Functional Updates with a Ref**
We'll **use a ref** to track  synchronously **instead of relying on state updates**.

### **Updated Code:**

---

## **Why This Fix Works**
✅ **Prevents skipping issues** by using  instead of relying on .
✅ **Ensures consistent updates** because refs update immediately, avoiding batching delays.
✅ **Fixes async state issues** where the second letter gets skipped due to React's state batching.

### **Next Steps**
1. **Replace your existing  with this version.**
2. **Test with  and .**
3. **Verify if the second letter is still skipped.**

This should resolve your issue! � Let me know how it works.
…nitiesPage-MemberButtonDebug

opportunities page bug
…2025-feb

Fixed About page bug at "WHAT IS CSES?", minor spelling checks across pages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants