Skip to content

Deprecate isValidClass #2374

@sebmarkbage

Description

@sebmarkbage

We should deprecate isValidClass. In 0.13, any function that returns an object with a render method will be a valid class.

We probably don't want to assume that there is a valid prototype because that doesn't allow the module pattern to be used:

function MyComponent(props) {
  return {
    render: function() {
      return <div />;
    }
  };
}

It's really difficult to validate these without invoking them. This is where a static type system shines. For a dynamic check, isValidClass would turn into: typeof fn === 'function' which doesn't need its own function.

Generally, you'll want to validate something extra about the class anyway. E.g. will it have a getDOMNode method on it? Does it render into a table cell?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions