2016-09-23 65 views
1

我知道在過去的React版本中,我們可以像這樣製作子組件。我想知道如何在React ES6中創建子組件。 是它使用的語法像React中的子組件ES6

class Row Extends MyFormComponent , Component {} 

或者是有其他的方式圓了這個方法?

+0

子組件?我的猜測是你正在創建一個新的React組件(它是一個對象)並將它存儲在另一個React.Component(這是另一個對象)的鍵中。我看不到它的美麗 – Borjante

+0

你可以參考這裏的答案http://stackoverflow.com/questions/41576711/in-reactjs-how-do-i-create-subcomponent-using-extends/41577285#41577285 – anandharshan

回答

7

我認爲你正在尋找的語法是:

MyFormComponent.Row = class Row extends React.Component { ... } 

由於@Borjante評論說,雖然,這只是一種方式下另一個組件組分量,有沒有關於特殊的「子」的行爲任何這一點。如果你認爲這是命名組件的好模式,那就去做吧。