Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

TypeScript, MobX-React, and RefObjects #616

Closed
42shadow42 opened this issue Dec 4, 2018 · 3 comments
Closed

TypeScript, MobX-React, and RefObjects #616

42shadow42 opened this issue Dec 4, 2018 · 3 comments
Labels
has PR Has PR, so will be fixed soon

Comments

@42shadow42
Copy link

42shadow42 commented Dec 4, 2018

When using a combination of TypeScript, MobX-React, and RefObjects, it becomes impossible to use strong typed RefObjects:

private searchForm: RefObject = React.createRef();

@action
onSearchSelected = (search: Search) => {
    this.searchForm.current.populateSearchForm(search); //This compiles but fails at runtime
    this.searchForm.current.wrappedInstance.populateSearchForm(search); //This succeeds at runtime, but won't compile
}

I believe this can be resolved, by using the new forwardRef API for react components

@42shadow42
Copy link
Author

I've put together the gist of what needs to happen, but I've broken some tests in the process, any help that can be providing fixing or deprecating the tests would be appreciated.

https://github.com/42shadow42/mobx-react/tree/patch-1

@42shadow42
Copy link
Author

@mweststrate I saw you fixed issues with reactivity and forwardRef on Observer, do you have any insight that might help fix reactivity of forwardRef on injector? I would really appreciate it!

@42shadow42
Copy link
Author

Fixed by #619

@mweststrate mweststrate mentioned this issue Feb 11, 2019
15 tasks
@mweststrate mweststrate added the has PR Has PR, so will be fixed soon label Mar 14, 2019
@github-actions github-actions bot mentioned this issue Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has PR Has PR, so will be fixed soon
Projects
None yet
Development

No branches or pull requests

2 participants