Ad
Disabling "expression Expected" From PhpStorm 10
I'm doing some react.js in PhpStorm 10 and even though JSX Harmony is enabled as the JavaScript language level, it still gives all sorts of nonsense errors.
So I disabled inspection completely for JavaScript but it still gives errors like "expression expected" or "Expecting newline or semicolon".
How do I get ride of those for JS?
<script type="text/babel">
var MyComponent = React.createClass({
render: function () {
return <div>
<h1><p>{this.props.text}</p></h1>
</div>;
}
});
React.render(<div><MyComponent text="text1" />
<MyComponent text="text2" /></div>, document.getElementById('container'));
</script>
Ad
Answer
At the moment such inline scripts with type="text/babel"
are not supported -- IDE only recognizes text/jsx
as type for now.
https://youtrack.jetbrains.com/issue/WEB-18276 -- watch this ticket (star/vote/comment) to get notified on progress.
Possible workarounds (that I'm aware of):
- change type to
text/jsx
(but then the in-browser babel most likely will not transform it, unless you can configure it somehow) - keep your JS code in a separate
.jsx
file
UPDATE: (23/03/2016) The aforementioned ticket is now marked as "Fixed" -- this functionality should be available in next update of 2016.1.
Ad
source: stackoverflow.com
Related Questions
- → Import statement and Babel
- → should I choose reactjs+f7 or f7+vue.js?
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → .tsx webpack compile fails: Unexpected token <
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → React Native with visual studio 2015 IDE
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
- → How do I determine if a new ReactJS session and/or Browser session has started?
- → Alt @decorators in React-Native
- → How to dynamically add class to parent div of focused input field?
Ad