0

I am currently reading the documentation about react and redux:

https://github.com/reactjs/redux/blob/5502940e7f139bb88bf0b67fcb838a7e3de3be6c/docs/basics/UsageWithReact.md

There, specifically in the code example here:

https://github.com/reactjs/redux/blob/5502940e7f139bb88bf0b67fcb838a7e3de3be6c/docs/basics/UsageWithReact.md#containersfilterlinkjs

you can see this line:

dispatch(setVisibilityFilter(ownProps.filter))

Now my question is, where does the 'filter' property in ownProps come from? Can somebody explain to me, where the connection is?

2 Answers 2

1

It is in the call to filterlink.

components/Footer.js

import React from 'react'
import FilterLink from '../containers/FilterLink'

const Footer = () => (
  <p>
    Show:
    {" "}
    <FilterLink filter="SHOW_ALL">
      All
    </FilterLink>
    {", "}
    <FilterLink filter="SHOW_ACTIVE">
      Active
    </FilterLink>
    {", "}
    <FilterLink filter="SHOW_COMPLETED">
      Completed
    </FilterLink>
  </p>
)

export default Footer

Sign up to request clarification or add additional context in comments.

Comments

0

ownProps are the props that were passed directly to the component by the React render call of the component's parent. In this case, the component in question is FilterLink. The FilterLinks are being passed a filter prop by the render method of its parent, Footer.js. e.g.

<FilterLink filter="SHOW_ALL">
  All
</FilterLink>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.