Skip to content

React 15 support #8

Closed
Closed
@npbee

Description

@npbee

Hello and thanks for your work! I recently attempted to get this library working with React@15.0.0-rc.2 and ran into some issues. It looks like there are a couple of updates in v15 that may require some changes.

Returning null now returns a comment node instead of noscript

https://facebook.github.io/react/blog/#rendering-null-now-uses-comment-nodes
facebook/react@3581406

I don't think this should have any functional effect, we'd just need to update the tests, e.g.:

assertEqual(
  <GatewayProvider>
    <div>
      <section>
        <Gateway into="foo">
          Hello World
        </Gateway>
      </section>
      <GatewayDest name="foo"/>
    </div>
  </GatewayProvider>,
  // should equal
  <div>
    <section>
      <noscript/>
    </section>
    <div>Hello World</div>
  </div>
);

would now just be:

assertEqual(
  <GatewayProvider>
    <div>
      <section>
        <Gateway into="foo">
          Hello World
        </Gateway>
      </section>
      <GatewayDest name="foo"/>
    </div>
  </GatewayProvider>,
  // should equal
  <div>
    <section></section>
    <div>Hello World</div>
  </div>
);

In development, ref and key are defined on props with warnings

facebook/react#5744

This is relevant because of this line:

https://github.com/cloudflare/react-gateway/blob/master/src/Gateway.js#L36

renderIntoGatewayNode(props) {
  delete props.ref;   <----
  this.gatewayRegistry.addChild(this.props.into, props.children);
}

When in development, this cause a runtime error because the props object is frozen via Object.freeze and we're in strict mode. The Object.freeze is not new to React 15, so as far as I can tell the reason this has not failed before is because at the time of calling delete props.ref, the ref was never actually defined on props so it just kind of noop-ed and carried along. But now in React 15, ref is always defined so that it can throw the warning about trying to access it as a normal prop.

I can't quite figure out what the original intent was for deleting ref from props. Is that still needed? The tests all seem to pass without it.

I have a branch going here that I'd be happy to send along as a PR, but I wanted to get some clarification on the ref thing first. Also I'm not sure if it'd be better to wait until we get a proper 15.0 version so we're not relying on an RC version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions