Coder Social home page Coder Social logo

Comments (9)

halayli avatar halayli commented on May 5, 2024

The documentation for this plugin is slightly incomplete. The reason I had to include it in my babelrc after upgrading to babel6 is to be able to assign jsx elements to jsx attributes. Otherwise, I'd get errors of this sort:

Module build failed: TypeError: App.js: Property value of JSXAttribute expected node to be of a type ["JSXElement","StringLiteral","JSXExpressionContainer"] but instead got "CallExpression"

For such code:

<Tab value="dashboard"
   icon={<FontIcon className="material-icons">dashboard</FontIcon>}
   label="DASHBOARD"
/>

Removing icon= fixes it.

from react-slingshot.

coryhouse avatar coryhouse commented on May 5, 2024

@halayli Per the docs it should only be enabled in production, so how would this solve your problem in dev?

from react-slingshot.

halayli avatar halayli commented on May 5, 2024

I had to enable in babelrc's development env. I couldn't find any other solution for now. This problem only showed up after I upgraded to babel 6.

from react-slingshot.

coryhouse avatar coryhouse commented on May 5, 2024

Ouch. Given the negative development impact, I definitely can't wire it up in dev. I've never seen this pattern before. Could you nest FontIcon as a child of Tab instead?

from react-slingshot.

halayli avatar halayli commented on May 5, 2024

This is a very common pattern in material-ui and ui-related libs in general. It's a handy pattern. I am not sure FontIcon can nest in the child but there are plenty other components that have other attributes taking jsx elements.

Given it's implications I understand why you wouldn't add it to dev. But I wonder how it was working in babel 5.x.

from react-slingshot.

barrystaes avatar barrystaes commented on May 5, 2024

@halayli you say

to be able to assign jsx elements to jsx attributes

Weird works for me .. i do this all the time, just not inline but using a variable:

const iconJsx = <FontIcon className="material-icons">dashboard</FontIcon> 
return <Tab value="dashboard" icon={iconJsx} label="DASHBOARD"/>

from react-slingshot.

halayli avatar halayli commented on May 5, 2024

@barrystaes it works with variables but not when you assign directly to icon.

from react-slingshot.

barrystaes avatar barrystaes commented on May 5, 2024

TLDR; I think the strength of react-slingshot is being complete but not complicated.
I dont think this addition makes it that much more complete to warrant the additional complexity. 👎

Long version; @coryhouse asks

Potential performance enhancement: https://babeljs.io/docs/plugins/transform-react-inline-elements/
Need to test and decide if the benefits justify the downsides. Any opinions?

I also vote against using it in react-slingshot.
From my viewpoint and that of a new user, i think this just complicates things (sourcecode readability, output code readability, debugability) but does not add value / solve a problem that i experience or even know of.

from react-slingshot.

coryhouse avatar coryhouse commented on May 5, 2024

Gotta agree with you @barrystaes. Thanks for the input! Until there's an alternative without the big downsides, this will have to stay out of the kit. Going to go ahead and close this as "won't fix" since there's nothing actionable we can do at this time.

from react-slingshot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.