mobxjs / mobx-react-lite

Lightweight React bindings for MobX based on React 16.8 and Hooks
https://mobx.js.org/react-integration.html
MIT License
2.13k stars 91 forks source link

Add support for computed.struct #231

Closed steelbrain closed 5 years ago

steelbrain commented 5 years ago

Currently mobx-react-lite methods behave with the default configuration of computed, would be nice to be able to configure them to behave like computed.struct.

This could be done by allowing consumers to specify options like equals to feed directly to the underlying computed calls.

danielkcz commented 5 years ago

Uh, if you mean useComputed, be advised it's deprecated and will be removed in 2.x (by the end of the week). Either way, the mobx-react-lite does not impose any restrictions on how or what you are supposed to use to construct your observables.

I will close this for now but try to elaborate more why do you think there should be something in this library. Keep in mind you can always do const [comp] = React.useState(() => computed(...)).

mweststrate commented 5 years ago

I think the issue is about useLocalState(() => ({ get something() {....}))? It is true that computed is not configurable in that case, but if you need more customization, it should suffice to call observable yourself explicitly, which have these possibilities, e.g. useLocalState(() => observable({ get something() { } }, { something: computed(options) })). In other words, it can be composed by using the lower level abstractions.

On Tue, Oct 15, 2019 at 6:16 PM Daniel K. notifications@github.com wrote:

Uh, if you mean useComputed, be advised it's deprecated and will be removed in 2.x (by the end of the week). Either way, the mobx-react-lite does not impose any restrictions on how or what you are supposed to use to construct your observables.

I will close this for now but try to elaborate more why do you think there should be something in this library. Keep in mind you can always do const [comp] = React.useState(() => computed(...)).

— 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-react-lite/issues/231?email_source=notifications&email_token=AAN4NBF4TVL45OYJAPFGP63QOX3GLA5CNFSM4JA7I5O2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBJRNIY#issuecomment-542316195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN4NBHLTIH3HWRSMHY2NALQOX3GLANCNFSM4JA7I5OQ .