Coder Social home page Coder Social logo

Comments (8)

elsassph avatar elsassph commented on May 28, 2024

No you're absolutely right - we should apply the default props in the JSON object.

from haxe-react.

elsassph avatar elsassph commented on May 28, 2024

@kevinresol please check PR #59 and tell me if the result is ok - I'll need to refactor a bit probably to add some unit tests.

from haxe-react.

kevinresol avatar kevinresol commented on May 28, 2024

I was using an extern component, so I guess the macro need to put in some runtime check for the existence of defaultProps in case of external class?

from haxe-react.

elsassph avatar elsassph commented on May 28, 2024

Ah damn, we can't do that. Macros don't run in JS; I guess Babel can do this discovery but we can't.

Ok I'll simply add back the guard to NOT inline extern components.

from haxe-react.

kevinresol avatar kevinresol commented on May 28, 2024

Well I mean you just use macro to generate some expressions like
type.defaultProps == null ? props : Object.assign({}, type.defaultProps, props)
and put that in the inline element code. If it is an extern class.

from haxe-react.

elsassph avatar elsassph commented on May 28, 2024

Hmmm maybe yes.

Can be a bit convoluted because props in your example will be either a literal object or Object.assign for spreads. You wouldn't want to be redundant, and we can't easily use intermediary variables, which means it may not be a lot more efficient than the default createElement call.

from haxe-react.

elsassph avatar elsassph commented on May 28, 2024

I pushed a depot for extern react components - it's safer like that and doesn't require a runtime replacement of React.createElement like babel do (see babel-helpers).

from haxe-react.

elsassph avatar elsassph commented on May 28, 2024

For what it's worth, Babel does use a runtime helper function - our compile-time literals are much more powerful for everything that isn't an extern!

from haxe-react.

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.