Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bit more typing required for DOM components #46

Closed
japgolly opened this issue Dec 8, 2014 · 2 comments
Closed

Bit more typing required for DOM components #46

japgolly opened this issue Dec 8, 2014 · 2 comments

Comments

@japgolly
Copy link
Owner

japgolly commented Dec 8, 2014

ReactTestUtils.renderIntoDocument doesn't accept a ReactElement but should.

> var div = React.createElement("div", null, "Hello ")
ReactElement {type: "div", key: null, ref: null, _owner: null, _context: Object…}

> var d2 = React.render(div, root)
ReactDOMComponent {_tag: "div", tagName: "DIV", props: Object, _owner: null, _lifeCycleState: "MOUNTED"…}

> d2.refs
undefined
React.createElement: String => ReactDOMElement <: ReactElement
React.render: ReactDOMElement => ReactDOMComponent
@japgolly
Copy link
Owner Author

japgolly commented Dec 9, 2014

Comparison with components:

> var HelloMessage = React.createClass({displayName: 'HelloMessage',
  render: function() {
    return React.createElement("div", null, "Hello ", this.props.name);
  }
});
function (config, children) {...}

>var h = React.createElement(HelloMessage, {name: "John"})
ReactElement {type: function, key: null, ref: null, _owner: null, _context: Object…}

> var h2 = React.render(h, root)
Constructor {props: Object, _owner: null, _lifeCycleState: "MOUNTED", _pendingCallbacks: null, _currentElement: ReactElement…}

> h2.refs
Object {}

@japgolly
Copy link
Owner Author

japgolly commented Dec 9, 2014

Virtual DOM builder isn't able to distinguish between a ReactElement being a DOM or component and I'm not going to use dependent types.

Therefore, b569877 is enough to close this.

@japgolly japgolly closed this as completed Dec 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant