Code completion for custom HTML tags in React / JSX

 

"WebStorm can also provide code completion for HTML tags and component names that you have defined inside methods in JavaScript or inside other components."

-- This is not happening; there is no dropdown showing component names that have already been defined in the same (index.js) file.

However, code completion for other aspects of JSX does work, for example div.class will code complete className.

 

WebStorm 2017.3.5
Build #WS-173.4674.32, built on March 6, 2018
Licensed to WebStorm Evaluator
Expiration date: April 18, 2018
JRE: 1.8.0_152-release-1024-b15 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

0
4 comments

Please can you provide a file/code snippet we can use to recreate the issue?

1
Avatar
Permanently deleted user

I am posting an index.js below. Create React App is the tool I used to setup the project:

 

import React from 'react';
import ReactDOM from 'react-dom';
import CreateReactClass from 'create-react-class';
import './index.css';


let from_object = {
name : 'Mary Smith',
address_1 : '398 Oceanside Ave.',
city : 'New York City',
state : 'NY',
zip : '93838'
};

let to_object = {
name : 'Earnest Hemmingway',
address_1 : '123 Grand Blvd.',
city : 'Tucson',
state : 'AZ',
zip : '37388'
};

// This is the parent
let Envelope = CreateReactClass(
{
render : function () {

return (
<div id="envelope_container">
<AddressLabel classChooser="first" name_line={this.props.frominfo.name} line2={this.props.frominfo.address_1} city={this.props.frominfo.city} state={this.props.frominfo.state} zip={this.props.frominfo.zip}/>
<Stamp id="stamp_id"/>
<AddressLabel classChooser="second" name_line={this.props.to_person.name} line2={this.props.to_person.address_1} city={this.props.to_person.city} state={this.props.to_person.state} zip={this.props.to_person.zip}/>

{/* All the parent prop 'module' data is dropped into the props object */}

</div>
);
}
}
);

let AddressLabel = CreateReactClass(
{

choose_class : function (x) {

if (x === "first") {
return "address";
} else {
return "address2";
}
},

render : function () {

return (
<div className={this.choose_class(this.props.classChooser)}>
<div id="name">{this.props.name_line}</div>
<div id="address_1">{this.props.line2}</div>
<div className="line3">
<span id="city">{this.props.city}</span>,{" "}
<span id="state">{this.props.state}</span>{" "}
<span id="zip">{this.props.zip}</span>
</div>
</div>
);

}
}
);

// let AddressLabel2 = CreateReactClass(
// {
// render : function () {
//
// return (
// <div id="receiveraddress" className="address2">
// <div id="name">{this.props.name_line}</div>
// <div id="address_1">{this.props.line2}</div>
// <div className="line3">
// <span id="city">{this.props.city}</span>,{" "}
// <span id="state">{this.props.state}</span>{" "}
// <span id="zip">{this.props.zip}</span>
// </div>
// </div>
// );
//
// }
// }
// );


let Stamp = CreateReactClass(
{

render : function () {
return (
<div className="stamp">
<span className="stampword">Stamp</span>
</div>
);

}
}
);



ReactDOM.render(<Envelope frominfo={from_object} to_person={to_object}/>, document.getElementById('root'));
0

To me, components are available in completion (2018.1 RC):

0
Avatar
Permanently deleted user

Ok I see it too, I needed to use ES6 classes to see it 

0

Please sign in to leave a comment.