Skip to content

Instantly share code, notes, and snippets.

@davidpfahler
Last active June 15, 2016 12:55
Show Gist options
  • Save davidpfahler/b4584a2521d1dde992e30984fbda4e5d to your computer and use it in GitHub Desktop.
Save davidpfahler/b4584a2521d1dde992e30984fbda4e5d to your computer and use it in GitHub Desktop.
Passing select props to child component with feross/standard
/*eslint no-unused-vars: ["error", { "varsIgnorePattern": "^_$" }]*/
import React, { Component } from 'react'
import Child from '../components/Child'
class ParentContainer extends Component {
componentDidMount () {
this.fetchData()
}
fetchData () {
// this.props.receiveData is a Redux prebound action creator
fetchTools().then(data => this.props.receiveData(data))
}
render () {
const { receiveData: _, ...rest } = this.props
return <Tools {...rest} />
}
}
@davidpfahler
Copy link
Author

I don't want to pass the prebound action to the "dumb" child component but the rest of the props; I suggest a convention which exists in
other languages such as Golang, i.e. to use _ as the throw away variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment