How to decouple state and UI (a.k.a. you don’t need componentWillMount)
Michel Weststrate
1.6K23

Michel Weststrate, I believe this is the right approach. Configuration (routing) as react components is against all logic.

I have some additional ideas:

  1. You can skip the view identifiers, a.k.a. “overview” and “document”. You should derive that from the lack or existence of data and whether this data is hidden or not. When the url change, mark content that shouldn’t be shown as hidden or remove it from state. Use `@computed` to memoize this check. I.e: `store.visibleDocuments` which refers only to the documents which should be shown.
  2. When the url change, you can just change data. No need run things like `showDocument`. Let the wonderful mobx observation takes care of the reaction to the data change.
Like what you read? Give Anton Stoychev a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.