The results of beautification are not what I expect.
This is what the code looked like before:
import React, { Component } from 'react';
class App extends Component {
constructor(){
super();
this.state = {
txt: "STATE text"
}
}
update(e) {
this.setState({txt: e.target.value})
}
render() {
return (
<div>
<input type="text"
onChange={this.update.bind(this)}/>
<div></div>
<h1>{this.state.txt}</h1>
</div>
);
}
}
App.propTypes = {
txt: React.PropTypes.string,
cat: React.PropTypes.number
}
App.defaultProps = {
txt : "default txt",
}
export default App;
The beautified code should have looked like this:
import React, { Component } from 'react';
class App extends Component {
constructor(){
super();
this.state = {
txt: "STATE text"
}
}
update(e) {
this.setState({txt: e.target.value})
}
render() {
return (
<div>
<input type="text"
onChange={this.update.bind(this)}/>
<div></div>
<h1>{this.state.txt}</h1>
</div>
);
}
}
App.propTypes = {
txt: React.PropTypes.string,
cat: React.PropTypes.number
}
App.defaultProps = {
txt : "default txt",
}
export default App;
The beautified code actually looked like this:
import React, {
Component
} from 'react';
class App extends Component {
constructor() {
super();
this.state = {
txt: "STATE text"
}
}
update(e) {
this.setState({
txt: e.target.value
})
}
render() {
return ( <
div >
<
input type = "text"
onChange = {
this.update.bind(this)
}
/> <
div > < /div> <
h1 > {
this.state.txt
} < /h1> <
/div>
);
}
}
App.propTypes = {
txt: React.PropTypes.string,
cat: React.PropTypes.number
}
App.defaultProps = {
txt: "default txt",
}
export default App;
Atom Beautify: Beautify EditorHere is a link to the debug.md Gist: https://gist.github.com/CorentinAndre/2abb11ee100f6834d9d2f921ad38e9c6
I have:
Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issueI can reproduce the defect at http://jsbeautifier.org/
Set e4x, and add preserve-inline to brace style, and that fixes this issue.

Thanks @bitwiseman
This issue has been automatically marked as stale because it has not had recent activity. If this is still an issue, please add a comment. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Set

e4x, and addpreserve-inlineto brace style, and that fixes this issue.