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

Added @:jsxStatic #81

Merged
merged 1 commit into from
Oct 4, 2017
Merged

Conversation

kLabz
Copy link
Contributor

@kLabz kLabz commented Oct 1, 2017

@:jsxStatic can be used to create functional components:

@:jsxStatic('render')
class Link {
    static function render(props:LinkProps)
    {
        return jsx('<a href={props.to}>{props.children}</a>');
    } 
}

// usage
function render()
{
     return jsx('<Link to="abc">Abc</Link>');
}

// replaced by
function render()
{
     return jsx('<Link.render to="abc">Abc</Link.render>');
}

Sorry for the whitespace too, these changes are the same as the other PR. You can view the diff without whitespace diff by adding &w=1 to the url.

case JsxAst.Node(isHtml, path, attributes, jsxChildren):
// parse type
var type = isHtml ? macro $v{path[0]} : macro $p{path};
type.pos = pos;

parseJsxStatic(type);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only if (!isHtml)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I'll fix that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated :)

@elsassph elsassph merged commit 078f26f into massive-oss:master Oct 4, 2017
@kLabz kLabz deleted the feature/jsxStatic branch January 17, 2019 08:53
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

Successfully merging this pull request may close these issues.

None yet

2 participants