r/reactjs • u/prithivir • Jul 24 '26
Discussion Do data structures actually influence how you build React components?
I tried learning DSA before, but never understood how it applied to everyday frontend work.
Recently, I built an undo/redo feature with Claude and realised it was using stacks. That made stacks much easier to understand than textbook examples.
I kept exploring and learned how seat-booking UIs can use matrices and how complex onboarding flows can be modelled as graphs.
Do you think about data structures when building React components? Any real-world examples?
55
Upvotes
View all comments
Show parent comment
7
u/vasind-5012 Jul 25 '26
not literally writing a class-based graph structure lol, more just thinking about it that way mentally when designing the flow. like step 3 depends on what you picked in step 2, step 5 only exists if a certain path was taken, that’s graph shaped even if the actual code is just a config object or a switch on state
zod discriminated unions is honestly probably the cleaner implementation for it tbh, type safety on each step’s shape based on the branch you’re in is nice. i just meant the mental model when sketching it out before writing code, not that the code itself needs to be some formal graph class