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

setting a defaultProps property on a component breaks the nodeName property of RenderContext #80

Open
tconroy opened this issue Mar 2, 2018 · 1 comment

Comments

@tconroy
Copy link

tconroy commented Mar 2, 2018

hey there,

if you do the following:

Example.js

import { h, Component } from 'preact';
class Example extends Component {
  render() {
    return (<div>hello, world</div>);
  }
}

Example.defaultProps = {
  foo: 'bar'
}

export default Example;

and then try to inspect the nodeName property of this class instance via RenderContext, you get an interesting looking object like this:

{
    [Function: Example]
    defaultProps: { foo: 'bar'}
}

I'm unsure what exactly is going on here. It looks like the component (as a function) is being assigned as a key to the nodeName property? how do we access this, or assert against it?

if you do this:

console.log( JSON.stringify(context.nodeName) );

it returns

undefined
@tconroy tconroy changed the title setting a .defaultProps attribute on a component breaks the nodeName property of RenderContext setting a defaultProps property on a component breaks the nodeName property of RenderContext Mar 2, 2018
@gnarf
Copy link
Collaborator

gnarf commented May 16, 2018

.nodeName should be === the function that generates it.

<div> = {nodeName: 'div'}
<Component> = {nodeName: Component}

Is this what you are seeing? or is there something different?

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

2 participants