generated from IvettaGoIT/react_vite
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from MargoMarm/feature/scroll-again
Feature/scroll again
- Loading branch information
Showing
10 changed files
with
138 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
18 changes: 17 additions & 1 deletion
18
src/components/ProductOrExerciseContainer/ProductOrExerciseContainer.jsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
import { useRef, useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { getSearchParams } from '../../redux/productsFilter/selectors'; | ||
import { Container } from './ProductOrExerciseContainer.styled'; | ||
|
||
export default function ProductsOrExercisesContainer({ children, ...props }) { | ||
return <Container {...props}>{children}</Container>; | ||
const containerRef = useRef(); | ||
const searchParams = useSelector(getSearchParams); | ||
|
||
useEffect(() => { | ||
console.log('scroll', containerRef.current.firstChild); | ||
containerRef.current.firstChild?.scrollIntoView(); | ||
}, [searchParams]); | ||
|
||
return ( | ||
<Container ref={containerRef} {...props}> | ||
{children} | ||
</Container> | ||
); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export const getProducts = state => state.products.products; | ||
export const getProductsCategories = state => state.products.categories; | ||
export const getIsLoading = state => state.products.isLoading; | ||
export const getSearchParams = state => state.products.searchParams; | ||
export const getHasMore = state => state.products.hasMore; |
This file contains 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