Skip to content

JSX Compiler interpolation alternatives. #51

Open
@DylanPiercey

Description

@DylanPiercey

This will likely never change as it is far too late but it bothers me so I want to at least mention it.

I think that using curlies "{}" for interpolation inside JSX is confusing, unintuitive and ugly. Typically curlies refer to an object or a block neither of which can actually exist inside the interpolation within JSX.

Parens "()" are typically used to enclose an expression which is exactly what is going on in JSX.

I propose that we switch from this:

<div a={ { b: 1 } }/>

Which is confusing for beginners because it looks like an object in an object, or if you are coming from mustache something different entirely.

To:

<div a=( { b: 1 } )/>

Here it would be easy to explain that, like everywhere else in javascript, parans are used to represent an expression which in this case returns an object to the attribute of the virtual div.

Just my thoughts, feel free to discuss or close.


This was originally posted here: https://phabricator.babeljs.io/T7074

Metadata

Metadata

Assignees

No one assigned

    Labels

    Proposal 2.0Proposals considerable for JSX 2.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions