Skip to content

Support ES6 #147

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

Closed
redak105 opened this issue Dec 30, 2016 · 7 comments
Closed

Support ES6 #147

redak105 opened this issue Dec 30, 2016 · 7 comments
Labels

Comments

@redak105
Copy link

redak105 commented Dec 30, 2016

Hello,
can I ask about support ES6 fat arrows function?

_renderContent = (color: string) => { 
  return ( 
     <View style={{backgroundColor: color}} \>
  );
};

Thank you,
redak105

@fkling
Copy link
Member

fkling commented Dec 30, 2016

react-docgen completely supports ES6. However it doesn't support many of the newer experimental proposals, such as public class fields, which is what you might be using? Can you please clarify your post?

Also see #137 which would solve that problem.

@redak105
Copy link
Author

redak105 commented Jan 4, 2017

Thanks for your reply.
I'm specifically interested in fat arrows functions. Are these supported?

@fkling
Copy link
Member

fkling commented Jan 18, 2017

If by support you mean "can react-docgen parse code that uses arrow functions", the answer is yes.

@redak105
Copy link
Author

redak105 commented Feb 1, 2017

Sorry for my late response.
I have this testing class. I run react-docgen. But I didn't get show method in my output.

`
/**

  • Test class
    */
    export default class TestClass extends Component {

    /**

    • Constructor

    • @Property props
      */
      constructor(props) {
      super(props);

      this.opacity = 0;
      };

    /**

    • show row
      */
      show = () => {
      opacity = 1;
      };

    /**

    • Render
      */
      render() {
      return (
      <View style={[styles.viewRow, {opacity}]}>

      {this.props.title}


      );
      }
      }

TestClass.propTypes = {
/**
* title
* @type {String}
*/
title: PropTypes.string.isRequired,
};
`

@DanielRamosAcosta
Copy link

DanielRamosAcosta commented Apr 7, 2017

@fkling I'm having errors with arrow functions in class methods as the render method... I have a component like this:

class Foo extends Component {
  (...)

  render = () =>
    <div>
      Foo!
    </div>
}

But it throws to me No suitable component definition found.... is there any solution to this? Maybe a handler?

@fkling
Copy link
Member

fkling commented Apr 7, 2017

That's what I meant when I mentioned in an earlier post

react-docgen completely supports ES6. However it doesn't support many of the newer experimental proposals, such as public class fields, which is what you might be using?

This is an example of a public class field, so it wasn't supported.

However, since then we have released v3.0.0-beta which uses Babylon7, which should be able to handle this case! You can install it via npm install react-docgen@next.

@DanielRamosAcosta
Copy link

I'll give it a shot, thanks for your work!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants