Skip to content

Expanding render() method behaviour #9338

@Dmytraw

Description

@Dmytraw

Regular render() method behaviour

Everytime we render a component we have to place it within a element-wrapper. Let's say this element is a div with CSS class myDiv.

import React, {Component} from 'react';

class RregularRenderBehaviour extends Component {
  render() {
    return (
      <div className="myDiv">
        <p className="myParagraph">Hi!</p>
        <p className="myParagraph">Hi!</p>
        <p className="myParagraph">Hi!</p>
     </div>
    );
  }
} 

Extended render() method behaviour

Maybe it's better to pass render() method two parametres:

  1. An element that will wrap up our jsx code that is returned (div) ;
  2. A CSS class that will be assigned to an element-wrapper (myDiv).
    Here is an example of what I am trying to say.
class ExtendedRenderBehaviour extends Component {
  render(div, "myDiv"){
    return (
        <p className="myParagraph">Hi!</p>
        <p className="myParagraph">Hi!</p>
        <p className="myParagraph">Hi!</p> 
    );
  }
}

If render() method didnt receive any parametres It will wrap jsx code with a div by default.

I think this enhancement can save time a bit and you dont have to worry that u didnt wrap your jsx code.

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