2016-12-29 49 views
0

我想在使用semantic-ui時使模板的組件分解並獲得編譯錯誤。 (意外的令牌(11:12))創建React組件,返回部分語義UI網格行

您可能需要一個合適的加載程序來處理此文件類型。

import React, { Component } from 'react'; 
import { Container, Label, Grid } from 'semantic-ui-react' 

export default class StatusLine extends Component { 
    constructor(props) { 
     this.state = props.fyrevm; 
    } 

    render() { 
     return (
      <Grid.Row> 
       <Grid.Column width={8}> 
        <Container textAlign='right'> 
         <Label sub>Score</Label><span>{this.state.score}</span> 
         <Label sub>Turn</Label><span>{this.state.turn}</span> 
         <Label sub>Time</Label><span>{this.state.time}</span> 
        </Container> 
       </Grid.Column> 
      </Grid.Row> 
     ); 
    } 
} 
+0

我會對主要問題發表評論。無狀態你的意思是不使用this.state,只使用道具參數? (仍然不會用super();)編譯。 –

回答

0

您確定已安裝semantic-ui-react

+0

是的。我有一個完整的應用程序可以工作,但我試圖將零件分成子組件。我希望此代碼的其他用戶能夠使用相同的外部網格行替換此組件,但不替換內容而不破壞外部模板和網格。 –

+0

嘗試在'this.state = props.fyrevm'之前添加'super();'。而且你的組件應該是一個無狀態的組件。 –