Last active
June 15, 2016 12:55
-
-
Save davidpfahler/b4584a2521d1dde992e30984fbda4e5d to your computer and use it in GitHub Desktop.
Passing select props to child component with feross/standard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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} /> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.