Skip to content

Suggestion to add functional option to component generator #1067

Closed
@CaitlinWeb-st

Description

@CaitlinWeb-st

Thank you for this wonderful library, it's helped me set up React in Rails when I'm new to Rails. It's especially nice to have rails g react:component for quickly creating new components. I'm using a lot of functional components in my project, though, so it's not as useful.

What about adding an option to make it a functional component? Something like rails g react:component --func or rails g react:component --function.

This would create:

import React from "react"
import PropTypes from "prop-types"
function SomeComponent() {
  return (
    <React.Fragment>
      Example: {this.props.example}
    </React.Fragment>
  );
}

SomeComponent.propTypes = {
  example: PropTypes.text
};
export default SomeComponent

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions