user605331
user605331

Reputation: 3788

How to auto-suggest class/function name in javascript live template?

In IntelliJ (or whatever variant) I am trying to make a "live template" to handle the boilerplate code when setting up PropTypes for React components. If I have the function Blink and want to have proptypes set up for it, how can I have a live template where the Blink part of the line Blink.propTypes is auto suggested for me? I'd like the IDE to guess at the name of that, but have it highlighted/selected so I can override it. I'm stuck on the suggestion part though.

// Existing function
function Blink(props) {
  return (
      ...
  )
}

// Manually coded propTypes
Blink.propTypes = {
    text: PropTypes.string.isRequired
};

//Simple live template, where I'd like the $NAME$ part to be smarter
$NAME$.propTypes = {
  $END$
}

Upvotes: 0

Views: 229

Answers (1)

lena
lena

Reputation: 93728

You can try jsClassName() - seems to be a best choice here:

enter image description here

classNameComplete() also looks suitable

Upvotes: 2

Related Questions