Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
This repository was archived by the owner on Sep 21, 2022. It is now read-only.

Killing React.createElement #49

Closed
Closed
@iddan

Description

@iddan

Problem

import React from 'react';
React.createElement();

Solution

Add to ReactDOM.render() and AppRegistry.registerComponent():

function prerender (tempalte) {
    if (typeof template !== 'object') {
        return template;
    }
    let { props: { children }} = template;
    delete template.props.children;
    return React.createElement(template.type, template.props, template.children.map(child => prerender(child)));
   
}

and

<div className="card">
    <span>hello</span>
</div>

will become

({
    type: 'div',
    props: {
        className: 'card',
        children: [
            {
                type: 'span',
                children: 'hello'
            }
        ]
    }
})

Why

  • The importance of semantic markup
  • React should not be a dev dependency for small modules it takes too much time to use. More than that if PropTypes will go native now no imports at all except for helpers!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions