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

TypeScript, MobX-React, and RefObjects #616

@42shadow42

Description

@42shadow42

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    has PRHas PR, so will be fixed soon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions