From Automation to Apps

From Automation to Apps

How PLC logic accidentally taught me React state management. Turns out, industrial automation and React aren't that different after all.

โ€ข By Ehsan Pourhadi โ€ข
Web Development Learning

Soโ€ฆ funny story.

A while ago I was playing with PLCs. Yep. Industrial stuff. Sensors, relays, ladders, blinking lights. Very factory-core. At the time I didnโ€™t think much of it, I was just trying to understand how machines think without exploding ๐Ÿ’ฅ (spoiler: theyโ€™re very unforgiving).

Fast-forward to me learning React, sitting in front of my laptop at 2am, te cold, brain fried, staring at useState like it personally offended me.

And thenโ€ฆ ๐Ÿ’ก WAIT A SECOND.

This feelsโ€ฆ familiar???


๐Ÿญ PLC brain activated

If youโ€™ve ever touched PLC programming (ladder logic, function blocks, whatever flavor), you know the deal:

  • Inputs come in (buttons, sensors, signals)
  • Logic runs every cycle
  • Outputs change based on the current state
  • Everything is predictable, reactive, and stateful

Back then I didnโ€™t call it โ€œstateโ€. I called it โ€œwhy is this motor still ON???โ€ ๐Ÿ˜ญ

But yeah, PLCs are basically:

Infinite loops that react to changes

Sound familiar yet?


โš›๏ธ Enter React (aka โ€œPLC but with JSXโ€)

When I first learned React, I was like:

โ€œWhy is my UI not updating?? Why is this state stale?? Why is everything re-rendering?? omgโ€

Classic beginner pain. Been there. Still there sometimes.

Then I realized something embarrassing:

React is just automation logic wearing a hoodie.

Hear me out ๐Ÿ‘‡


๐Ÿ” PLC Scan Cycle = React Render Cycle

In PLCs:

  1. Read inputs
  2. Execute logic
  3. Update outputs
  4. Repeat forever โ™พ๏ธ

In React:

  1. State/props change
  2. Component re-renders
  3. UI updates
  4. Repeat forever โ™พ๏ธ

BRO.

Same movie. Different actors.

Except React yells at you if you mutate state and PLCs yell at you by breaking real machines ๐Ÿซ 


๐Ÿง  State is just memory (stop overthinking it)

In PLC land:

  • You store flags
  • You latch bits
  • You remember what happened last cycle

In React:

  • useState
  • useReducer
  • useRef (aka โ€œpls donโ€™t re-renderโ€ button)

Same idea. Different syntax. More memes.

Once I stopped treating React state like magic and started treating it like PLC memory, everything clicked.

Like:

  • A button click = digital input
  • setState = coil energizing
  • Conditional rendering = contacts opening/closing

I felt so smart for like 3 minutes ๐Ÿ˜‚


๐ŸŽฎ Building an interactive story (because why not?)

So naturally, instead of just understanding this quietly like a normal personโ€ฆ

I built a tiny interactive thing.

An app where:

  • Inputs toggle state
  • Logic decides what happens next
  • UI reacts visually

Basically a PLC simulator disguised as a React app.

Was it overkill? Yes. Did it help me learn? BIG YES. Did I push it to GitHub at 3am with a messy commit message? Absolutely.


๐Ÿ˜ต My struggles (aka honesty time)

Letโ€™s be real:

  • I broke stuff
  • I misunderstood hooks
  • I forgot dependencies in useEffect (donโ€™t judge me)
  • I re-rendered the universe by accident

Multiple times.

But thatโ€™s kinda the point, right? Iโ€™m just a curious dev smashing concepts together and seeing what survives ๐Ÿ”ฅ


๐Ÿš€ Why this mindset helped me

Thinking in automation logic made React less scary.

Instead of:

โ€œReact is confusingโ€

It became:

โ€œOh, this is just reactive logic with prettier outputsโ€

And that mindset shift? Game changer.

If you come from:

  • PLCs
  • Arduino
  • Game dev
  • Even Excel formulas ๐Ÿ˜…

You already understand React more than you think.


๐Ÿ’ฌ Final thoughts (before I overthink this)

If youโ€™re learning React and feel stuck:

  • Build weird things
  • Compare it to stuff you already know
  • Donโ€™t wait to โ€œfeel readyโ€

Just do itโ„ข๏ธ.

Worst case? You learn something. Best case? You accidentally connect factories to frontends and feel like a wizard ๐Ÿง™โ€โ™‚๏ธโœจ

Alright, Iโ€™ll stop here before this turns into a book. Thanks for reading, Now go break something and learn ๐Ÿ’™

Tags: #React #PLC #State Management #Automation
Ehsan Pourhadi
Software Developer

Experienced software developer passionate about creating impactful digital experiences with modern web technologies and thoughtful design.

70+
Projects Completed
50+
Happy Clients
12+
Years Experience
100%
Client Satisfaction
ยฉ 2025 Ehsan Pourhadi. All rights reserved.
Made with
and
using
TreeStone
Running cat