2016-12-25 10 views
9

私はいくつかの基本的な反応コードを崇高なテキストで書き始めました。構文の強調表示は次のようになります。その一部が強調表示されています。私は完全な構文のハイライトを見るために使用することができます示唆された崇高なプラグインはありますか?反応コードの昇華での構文強調表示

enter image description here

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); 

EDIT:[いくつかの不正な構文を修正、追加のコードテキスト]

+0

sublime3またはsublime2を使用していますか? Check、答えを更新しました。 – MYGz

+0

あなたのコードに問題があるかもしれないと思いますが、タグやその他のものを閉じるのを忘れているかもしれません。 – Codesingh

答えて

16

としてはバベルをインストールしても問題が修正されプラカシュによって指摘。 sublime3上

のインストールバベル:

  1. 押しCtrlキー + Shiftキー + P
  2. その後Package control: Install Package
  3. その後Babelを入力して、最初のオプションを選択しinstallを入力し、最初のオプションを選択します。それは少しの時間でバベルをインストールします。
    編集:最初のオプションパッケージ名は'Babel-Snippets'で、下記のコメントに記載されています。
  4. 次に、[Babel Syntax]を選択します。 View > Syntax > Babel > Javascript

私はそれをテストチェック:

enter image description here

+0

が修正されました。まだ同じ... –

+0

テキストを貼り付けることはできますか?私はそれをテストします。ありがとう、 – MYGz

+3

実際には、バベルパッケージはバベルとは呼ばれず、バベルスニペットと呼ばれていたので、私は混乱しました。いずれにせよ、それは私のために働いた。 –

2

私は崇高で同じ問題がありました。

私はbabel-sublimeプラグインをインストールしていました。ここで

はリンクです - https://github.com/babel/babel-sublime

は、それはあまりにもあなたの問題を解決を願っています。

+0

私のパッケージマネージャーの 'Babel'オプションは表示されません。手動でインストールしましたか? –

+0

それは昇華3のためです。 –

+0

崇高なテキスト2をお持ちですか? –

関連する問題