Skip to content

Need something more robust to handle React Router params #5

Open
@benlesh

Description

@benlesh

According to the documentation on component lifecycle with react-router, users should be making ajax requests and using route params both at componentDidMount and componentDidUpdate. It seems like we might need a decorator (or the decorator) to handle more lifecycle hooks than just dispatchOnMount.

We can either do several decorators for each lifecycle hook we care about, which would incur the overhead of more higher-order components, or, we can have a single HoC to rule them all.

@connect(stuff, stuff)
@dispatchOnMount(stuff)
@dispatchOnUpdate(stuff)
class MyComponent extends React.Component {
  // stuff
}

// or something like 
const MyComponent = compose(
  connect(stuff, stuff),
  dispatchOnMount(stuff),
  dispatchOnUpdate(stuff)
)((props) => (<div>weee</div>));

Or the one lifecycle decorator idea:

@connect(stuff, stuff)
@dispatch({
  onMount: [stuff, stuff],
  onUpdate: [stuff]
})
class MyComponent extends React.Component {
  // stuff
}

// or something like 
const MyComponent = compose(
  connect(stuff, stuff),
  dispatch({
    onMount: [stuff, stuff],
    onUpdate: [stuff]
  })
)((props) => (<div>weee</div>));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions