Skip navigation
❌ Conditional rendering loses form state in React.
0:00 / 0:22

❌ Conditional rendering loses form state in React.

George Moller

@_georgemoller118K followers

Visit on X
937 likesDownloadOriginal post

74,295 views

❌ Conditional rendering loses form state in React. ✅ React 19's Activity API preserves it. e.g. Switch between steps → your data stays. Effects cleanup automatically → no wasted resources.

47 Comments

Comments from the original post on X (Twitter)

  • Jos Graas 🇱🇺's profile picture

    @graasdev

    Ah thats nice. No longer need to wrap values in context or in parent

    6 likes

  • George Moller's profile picture

    @_georgemoller

    @indiegraas Exactly! :100

    1 like

  • Jos Graas 🇱🇺's profile picture

    @graasdev

    Naming this activity makes absolutely no sense does it 😆

    1 like

  • Zeeshan Zubair's profile picture

    @zeeshanzubair_

    Exactly, losing form state with conditional rendering is such a pain. Activity API feels like a game-changer for building multi-step forms cleanly.

    4 likes

  • George Moller's profile picture

    @_georgemoller

    Agree! so much easier and cleaner approach.

    1 like

  • Adetunji | Software Engineer (Web & Mobile)'s profile picture

    @itzadetunji1

    This is really good and onboarding on apps would be much simpler now with this structure

    3 likes

  • Roxana Muntian's profile picture

    @roxanamuntian

    Looks like a powerful feature in React 19. On my current project I use RHF, but no multi-step forms yet. Guess I’ll see how I handle those (no React19 on the project) 😢

    2 likes

  • George Moller's profile picture

    @_georgemoller

    actually RHF doesn't use refs instead of state? this shouldn't be a problem then

    2 likes

  • Roxana Muntian's profile picture

    @roxanamuntian

    RHF uses uncontrolled components under the hood and tracks values via refs. Was curious how to handle the multistep forms. Turns out it’s pretty straightforward - one useForm instance at the top level(keeps data even when steps unmount) - FormProvider to share the form instance using React Context - useFormContext in each form step to read the form instance

    7 likes

  • George Moller's profile picture

    @_georgemoller

    Oh cool! Pretty straight forward then.

    1 like

  • Austin K's profile picture

    @austinkdev

    Love the video

    1 like

  • George Moller's profile picture

    @_georgemoller

    Thanks Austin!

    1 like

  • Lou Greenwood's profile picture

    @LouGreenwood

    Ever heard of this thing called #EmberJS?

    1 like

  • George Moller's profile picture

    @_georgemoller

    damn I used to work with Ember JS back in the day!

    1 like

  • Lou Greenwood's profile picture

    @LouGreenwood

    Come back!

    1 like

  • Santi's profile picture

    @smallchano

    nice alternative to using context but not super valuable for more complex forms where you are going to need context anyway imo

    1 like

  • Olwiba 🤩's profile picture

    @Olwiba

    This is epic, what software do you use to make these videos?

    1 like

  • George Moller's profile picture

    @_georgemoller

    hey! I use remotion for these

    2 likes

  • Florin D's profile picture

    @Florin67086276

    Another approch is to use switch case

    1 like

  • nyx's profile picture

    @Niyxuis

    the number of times i've jury-rigged useRef to hold form state between steps just to avoid this exact problem. Activity API feels like an apology letter from the React team

    1 like