javascript - plugin - resaltado de sintaxis para reaccionar código en sublime
sublime text packages manager (3)
Empecé a escribir un código React básico en texto sublime. Así es como se ve mi resaltado de sintaxis. Está en parte resaltado. ¿Hay algún complemento sublime sugerido que pueda usar para ver un resaltado de sintaxis completo?
import React, { Component } from ''react''
import { connect } from ''react-redux'' // <-- is the glue between react and redux
import { bindActionCreators } from ''redux''
import { selectBook } from ''../actions/index''
// there is no intrinsic connection between React and Redux
// they are two seperate libraries
// they are connected using a seperate library called ReactRedux
// container? its a React component that hasa direct connection to state managed by Redux
class BookList extends Component {
constructor(props) {
super(props)
//this.props = props;
}
renderList() {
return this.props.books.map((book) => {
return (
<li key={book.title} className="list-group-item">{book.title}</li>
)
})
}
render() {
return (
<ul className="list-group col-sm-4">
{this.renderList()}
</ul>
)
}
}
// function is the glue between react and redux
function mapStateToProps(state) {
// Whatever gets retrieved from here will show up as props inside
// of book-list
return {
books: state.books
}
}
// anything returned from this function will end up as props on the BookList container
function mapDispatchToProps(dispatch) {
return bindActionCreators({selectBook: selectBook}, dispatch)
}
// Promote BookList from a component to a container - it needs to know
// about this new dispatch method, selectBook. Make it available as a prop
export default connect(mapStateToProps, mapDispatchToProps)(BookList);
EDITAR: [Se corrigió una sintaxis incorrecta, se agregó texto del código]
La instalación de babel corrige el resaltado de sintaxis.
Pasos para instalar babel en sublime3:
- Para Windows: Presione Ctrl + Shift + P Para mac: Cmd + Shift + P
- Luego escriba
instally seleccionePackage control: Install Package - Luego escribe
Babely selecciona''Babel-Snippets''. Instalará babel en unos instantes. - A continuación, establezca la sintaxis de Babel en Sublime3 Editor desde :
View > Syntax > Babel > Javascript
Para algunos usuarios, faltaba Babel en el paso 4. Además, pueden instalar Babel siguiendo los mismos pasos y seleccionando Babel esta vez en lugar de Babel-Snippets en el paso 3.
Compruebe que lo he probado:
Necesitas instalar el plugin babel-sublime .
Puedes instalarlo desde el package control de package control de sublime.
Aquí está el enlace - https://github.com/babel/babel-sublime
Pude resolver esto estableciendo la sintaxis en JSX. No necesité instalar este plugin.