gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)

Home Page:http://gaearon.github.io/react-hot-loader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Child component methods not available to use via refs from the parent component

maliyshock opened this issue · comments

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

What you are reporting: Bug.

Expected behavior

What you think should happen: Child component methods should be available for use via refs from the parent component this.childComponentRef.current.childMethod()

Actual behavior

What actually happens: this.childComponentRef.current.childMethod() throws error "childMethod is not a function", cas it is undefined.

If I replace this part

export default hot(withErrorBoundary(
    childComponent,
    ErrorBoundary,
));

To this

export default childComponent;

Child methods would be available by the parent component via ref

Environment

React Hot Loader version: 4.8.5

Run these commands in the project folder and fill in their results:

  1. node -v: v12.13.0
  2. npm -v: 6.12.0

Then, specify:

  1. Operating system: Mac Os High Sierra 10.13.4
  2. Browser and version: Chrome 79.0.3945.117

Reproducible Demo

Sorry guys. It will take a bunch of time to create a new project with environment end stuff.

hot creates a "boundary" around given component. Usually you don't need to pass any props via those boundaries (and usually you have to wrap only your top level component)