Hi Hrushikesh, I think you’ve misunderstood a little bit.
Josh J
1

Josh, first of all, thanks for replying. Your example is little more nuanced and yes, in your case, it does help to check it.

But let me explain where I was coming from.

I understand its all optional but then, its not. eslint will cry foul if I do something like this:

type Props = {

title: string,

description: string

}

ContainerComp extends Component {

// react bla bla

render (props: Props) {

const {title, description, dc1Props, dc2Props} = props

return (

<h1>{title}</h1>

<h3>{description}</h3>

<DumbComponent1 {…dc1Props} />

<DumbComponent2 {…dc2Props} />

)

}

The minimum I need to do, to make eslint happy, is this:

type Props = {

title: string,

description: string,

dc1Props: Object,

dc2Props: Object

}

But now, using Object feels dirty, although Container doesn’t care about child props and expects child to fully deal with them.

If structured right, most smart and container components will fall into this pattern. Of course, there will be use cases where container or smart component does more and for them, as you showed, it makes sense to have type checking. But for purely passthrough ones, it becomes a forced chore.

Hopefully this makes my perspective a bit clearer.

A single golf clap? Or a long standing ovation?

By clapping more or less, you can signal to us which stories really stand out.