If you're willing to refactor your app's component structure, you can create a common ancestor for <Filter />
and <ProductList/>
that passes state to both components as props. So instead of having this:
<App>
<SideBar/>
<ProductsInterface>
<ProductList>
<Filter/>
</ProductList>
</ProductsInterface>
</App>
You would have something like this:
<App>
<ProductInfo> //product-related state lives here
<Sidebar/>
<Filter/>
<ProductsInterface>
<ProductList/>
</ProductsInterface>
</ProductInfo>
</App>
This allows you to put the filter at the bottom of the sidebar, since the components are siblings. <Filter/>
could then receive functions like filterProducts()
as props from <ProductInfo/>
(its immediate parent). This would look like the following in ProductInfo.js
's render method:
<Filter propName="this.filterProducts"></Filter>
Then set up your onClicks
in <Filter/>
to call the function from its props, which will update the state in <ProductInfo/>
and by extension the contents of <ProductList/>
(since it's receiving the <ProductInfo/>
state as props).
This pattern is called lifting state up and is fairly common in React applications. I would definitely recommend researching it further as you develop your strategy for organizing your component tree.