Mobx: Update documentation for useAsObservableSource hook

Created on 6 Oct 2020  Â·  4Comments  Â·  Source: mobxjs/mobx

Hello,

Sorry in advance if this is something that is already planned or in progress, but reading through the React integration part in the docs (https://mobx.js.org/react-integration.html) I noticed few small "problems" with the part of the documentation that mentions useAsObservableSource hook (https://mobx.js.org/react-integration.html#computed-props).

  1. Link pointing to useAsObservableSource doesn't point to the proper place. It points to this https://github.com/mobxjs/mobx-react#useasobservablesource-hook. This section doesn't exist on mobx-react github page, but it does exist on mobx-react-lite (https://github.com/mobxjs/mobx-react-lite/#useasobservablesourcetsource-t-t-deprecated)
  2. useAsObservableSource is deprecated as indicated here https://github.com/mobxjs/mobx-react-lite/tree/master#useasobservablesourcetsource-t-t-deprecated and here https://github.com/mobxjs/mobx-react-lite/blob/master/src/useAsObservableSource.ts#L8

I know that having a warning in development is a good way to get notified about this, but maybe adding some info about deprecation in docs directly would just make it more obvious this isn't really a recommended hook to use anymore.

Also, I wasn't sure if I should open this issue in mobx-react repo because the topic is this React hook, but it's also about docs and those are located in this main repo here.

I didn't just want to randomly open a PR because I didn't know if this is something you would want addressed and how should it actually be addressed it if you want it to be addressed.

âť” question

All 4 comments

Hmm that looks like some changes in the docs were list :/. It should be
using useEffect instead to sync the prop into the observable.

On Tue, Oct 6, 2020 at 9:51 AM Marko Antolić notifications@github.com
wrote:

Hello,

Sorry in advance if this is something that is already planned or in
progress, but reading through the React integration part in the docs (
https://mobx.js.org/react-integration.html) I noticed few small
"problems" with the part of the documentation that mentions
useAsObservableSource hook (
https://mobx.js.org/react-integration.html#computed-props).

  1. Link pointing to useAsObservableSource doesn't point to the proper
    place. It points to this
    https://github.com/mobxjs/mobx-react#useasobservablesource-hook. This
    section doesn't exist on mobx-react github page, but it does exist on
    mobx-react-lite (
    https://github.com/mobxjs/mobx-react-lite/#useasobservablesourcetsource-t-t-deprecated
    )
  2. useAsObservableSource is deprecated as indicated here
    https://github.com/mobxjs/mobx-react-lite/tree/master#useasobservablesourcetsource-t-t-deprecated
    and here
    https://github.com/mobxjs/mobx-react-lite/blob/master/src/useAsObservableSource.ts#L8

I know that having a warning in development is a good way to get notified
about this, but maybe adding some info about deprecation in docs directly
would just make it more obvious this isn't really a recommended hook to use
anymore.

Also, I wasn't sure if I should open this issue in mobx-react repo
because the topic is this React hook, but it's also about docs and those
are located in this main repo here.

I didn't just want to randomly open a PR because I didn't know if this is
something you would want addressed and how should it actually be addressed
it if you want it to be addressed.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx/issues/2487, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAN4NBEGUWZSZQEBUQWAM5TSJLLA7ANCNFSM4SFXHJ4A
.

Hmm that looks like some changes in the docs were list :/. It should be using useEffect instead to sync the prop into the observable.

You want me to maybe create a PR to update this? I can probably do it today/tomorrow.

If I understand it correctly, it should just use offset inside useLocalObservable and update it inside a useEffect, is that correct? And remove useAsObservableSource entirely from that example.

Also then, the link and any reference to useAsObservableSource should probably be removed from that part of docs.

Yes, all correct. PR would be great!

On Tue, Oct 6, 2020 at 10:42 AM Marko Antolić notifications@github.com
wrote:

Hmm that looks like some changes in the docs were list :/. It should be
using useEffect instead to sync the prop into the observable.

You want me to maybe create a PR to update this? I can probably do it
today/tomorrow.

If I understand it correctly, it should just use offset inside
useLocalObservable and update it inside a useEffect, is that correct? And
remove useAsObservableSource entirely from that example.

Also then, the link and any reference to useAsObservableSource should
probably be removed from that part of docs.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/mobxjs/mobx/issues/2487#issuecomment-704154893, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAN4NBGO7ZNIC2YFCMLRJR3SJLQ7LANCNFSM4SFXHJ4A
.

Thanks for the PR!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

geohuz picture geohuz  Â·  3Comments

kirhim picture kirhim  Â·  3Comments

bb picture bb  Â·  3Comments

thepian picture thepian  Â·  3Comments

mehdi-cit picture mehdi-cit  Â·  3Comments