Skip to content

Instantly share code, notes, and snippets.

@imdongchen
Created October 2, 2018 14:53
Show Gist options
  • Save imdongchen/46ad6f4fdfab449bbd33931b0f1336ff to your computer and use it in GitHub Desktop.
Save imdongchen/46ad6f4fdfab449bbd33931b0f1336ff to your computer and use it in GitHub Desktop.
function Profile(props) {
const { name, age } = props
return (
<div>
<h2>{name}</h2>
<div>{age}</div>
<Detail {...props} />
</div>
)
}
// usage, say, connect to redux
const ConnectedProfile = connect(state => ({
name: state.name,
age: state.age,
gender: state.gender, // this prop appears not necessary
})(Profile)
@hozefaj
Copy link

hozefaj commented Oct 4, 2018

Does this work better?

function Profile(props) {
	const { name, age, ...rest } = props
  return (
		<div>
			<h2>{name}</h2>
			<div>{age}</div>
			<Detail {...rest} />
		</div>
	)
}

// usage, say, connect to redux
const ConnectedProfile = connect(state => ({
	name: state.name,
	age: state.age,
})(Profile)

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