Code Monkey home page Code Monkey logo

Comments (7)

bvic23 avatar bvic23 commented on July 17, 2024

Hey @sibelius! Thanks for reporting, I will fix this soon.

from babel-plugin-functional-hmr.

bvic23 avatar bvic23 commented on July 17, 2024

@sibelius Could you provide some more context?

from babel-plugin-functional-hmr.

kylealwyn avatar kylealwyn commented on July 17, 2024

Getting the same thing. I think I've narrowed it down to the ...props. Seems like it's barfing on the "rest" syntax

from babel-plugin-functional-hmr.

bvic23 avatar bvic23 commented on July 17, 2024

@kylealwyn @sibelius I'm not a JS expert but it seems like invalid syntax to me: AFAIK you can't use spread syntax in a destruct expression (props). Valid syntax would be:

export const Text = ({ style, children, capitalized, props }: Object) =>
  <RNText style={[styles.font, style]} {...props}>
    {capitalized ? capitalizeFirstLetter(children) : children}
  </RNText>;

from babel-plugin-functional-hmr.

sibelius avatar sibelius commented on July 17, 2024

In fact, you can

from babel-plugin-functional-hmr.

bvic23 avatar bvic23 commented on July 17, 2024

@sibelius seems like you are way more experienced than me please help me and send a PR with the fix

from babel-plugin-functional-hmr.

kylealwyn avatar kylealwyn commented on July 17, 2024

@bvic23 The syntax and method is called "rest" parameters: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters

It works the same for arrays as it does with objects. when destructuring, it effectively assigns the rest of the object or array into the variable. take for example:

const obj = {
   a: 1,
   b: 2,
   c: 3,
};

const { a, ...rest } =  obj;
// a is 1 here, rest is { b: 2, c: 3 }

This method works nicely with React because you may only want to pluck a couple properties out of the props arg and pass the rest down to the native view.

I have no experience with babel transforms and it's AST process but I'm happy to help in any way

from babel-plugin-functional-hmr.

Related Issues (14)

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.