Skip to content

Duplicate ThemeProvider causing unnecessary re-renders and potential context conflicts #271

@riddhimagupta2

Description

@riddhimagupta2

Currently, ThemeWrapper (ThemeContext Provider) is being used in both main.tsx and App.tsx, which leads to duplicate context wrapping.

Problem

  • ThemeWrapper is wrapped twice in the component tree
  • This creates multiple instances of the same context
  • It may cause unnecessary re-renders and inconsistent theme state behavior

Current Structure

  • main.tsx → ThemeWrapper
  • App.tsx → ThemeWrapper (again)

Impact

  • Performance overhead due to duplicate providers
  • Potential theme toggle inconsistency
  • Poor React architecture practice
  • Harder debugging and maintenance

Expected Behavior

ThemeWrapper should be used only once at the root level (in main.tsx), and removed from App.tsx.

Suggested Fix

Remove ThemeWrapper from App.tsx and keep it only in main.tsx.

Additional Notes

This follows React best practices where Context Providers should wrap the app only once at the top level.

Contributor Checklist

  • I am participating via GSSoC
  • I have read the contribution guidelines
  • I checked for existing issues before creating this

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions