Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

React.forwardRef breaks SSR on prepare #115

Open
rynocouse opened this issue Jul 17, 2018 · 2 comments
Open

React.forwardRef breaks SSR on prepare #115

rynocouse opened this issue Jul 17, 2018 · 2 comments

Comments

@rynocouse
Copy link

Type of issue

bug

Description

When wrapping a stateless component in a React.forwardRef SSR breaks on prepare.

Current behavior

Error:

TypeError: type is not a function
[36m at prepareElement node_modules/fusion-react-async/src/prepare.js:59:29�

Component:

const Slide = React.forwardRef((props: Props, ref) => {
  return (
     <Styled.SlideOpacity
       $active={props.active}
       $leavingActive={props.leavingActive}
       $ref={ref}
    >
       {props.children}
    </Styled.SlideOpacity>
   );
});

Expected behavior

Wrapping stateless component in React.forwardRef should render SSR without an error.
React Docs - Forwarding Refs

Steps to reproduce

  1. Wrap a stateless component in React.forwardRef
  2. Reload page

Your environment

  • fusion-react-async version: 1.2.3

  • Node.js version: v8.11.3

  • npm version: 5.6.0

  • Operating System: OSX 10.13.5

@rtsao
Copy link
Member

rtsao commented Jul 17, 2018

Thanks for the report. Sounds like this might be a similar to the one fixed in #80

@puppybits
Copy link

ForwardRefs don't work for me either. Adding a check at line 55 in prepare.js fixes it.

// current
if (typeof type === 'string' || isFragment(element)) {

// fix
if (typeof type === 'string' || isFragment(element) || isForwardRef(element)) {

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants