2016-09-25 52 views
0

我正在React中設計/創建應用程序,但我需要一些幫助來構建整個事情。需要幫助構建React應用程序

的應用程序,我想創建是建立如下: enter image description here

現在,我對如何構建這個幾個問題,什麼反應插件或框架派上用場:

  1. 應該將「過濾器」欄作爲主佈局的一部分(「主頁面」)?
  2. 我認爲react-router是反應路由的好選擇嗎?
  3. 當數據(包括顯示和操作)的工作,是Flux好東西一起工作呢?或者Flux與數據無關?
  4. 我會從ASP.Net WebAPI檢索我的數據。這是我通常用「簡單的」XmlHttpRequest/jquery ajax做的事嗎?還是有更多的「反應」?

  5. 額外:是否有特定原因使用Redux?我真的不明白的使用:)

在此先感謝您的幫助。

+0

1,它應該是在導航欄的組成部分。 2.即使反應路由器是一個不錯的選擇,你有其他的選擇,你可以檢查。 3.我不知道這麼多的流量,你應該閱讀他們的GitHub文檔。 4.您可以在componentDidMount時創建$ .get,因爲React對組件執行某些類型的事務時具有「回調」。 5.終極版是描述陳述如何變化的減速,這是更先進的,但你也可以看一下,如果你要開始它可能看起來很複雜.. – MiGu3X

+0

如果過濾器值應通過導航通過?例如,這可能是一個「年份」過濾器,用於過濾顯示的當前數據?我是否爲此使用上下文? – Nsevens

回答

1

我想你可以有一個這樣的佈局:

<App> 
    <Navbar /> { /* Here you show the username also, this view will depend on props */ } 
    <Layout /> { /* Here you may have the content and the sidenav */ } 
</App> 

應用是頂部部件,即通過道具例如在渲染()中的主容器,你將有

// You should treat this as a Page component, the one that grabs 
// data and passes it as props to another components 
export default class AppPage extends React.Component { 
    render() { 
     return (<AppLayout { ...this.props } />); 
    } 
} 

export default class AppLayout extends React.Component { 
    render() { 
     return (
      <Navbar someProp={ this.props.someProp } /> 
      { this.props.children } 
     ); 
    } 
} 

路由器可以是例如:

<Router history={ browserHistory }> 
    <Route path="/" component={ App }> 
    <IndexRoute component={ Landing } /> 
    <Route path="/index" component={ Layout } /> 
    </Route> 
</Router> 

IndexRoute是'/',你可以說哪些組件應該是我們的例如,如果您路由到/ layout {this.props。兒童}在AppLayout將渲染爲<Layout />組件。

我建議你閱讀這篇文章:https://facebook.github.io/react/docs/thinking-in-react.html 更好地瞭解如何應對作品...希望它幫助

+0

謝謝你的鏈接。使基本原則(道具,狀態)更清晰一些...... – Nsevens