Skip to content
This repository was archived by the owner on Jul 19, 2019. It is now read-only.

Don't return a div but just an array (React 16) #298

@marcelhageman

Description

@marcelhageman

Right now I can't do this in CSS:

input:focus + label { color: red; }

Because the output for the react-autocomplete contains the input element inside a div.

Instead, I'd like to be able to output only an input element and render it right beside a label, so I can focus the input field and style the next sibling label element accordingly.

Since React 16 I believe you can also render as follows:

const renderAutocomplete = [
  {this.props.renderInput(...)},
  {open && this.renderMenu()},
  {this.props.debug && ...}
];

You'd need to provide a key attribute to each child.

The containing div could be skipped since it offers no functional meaning, you could make it the default for old-times sake.

const { renderWrapper } = this.props;

return (
  renderWrapper
    ? <div style={{ ...this.props.wrapperStyle }} {...this.props.wrapperProps}>
        {renderAutocomplete}
      </div>
    : renderAutocomplete
);

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions