From 634f2b3b751d12efee3a47f22e22d85bc24d8a8b Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Thu, 16 Feb 2023 16:00:18 +0500 Subject: [PATCH] dom nesting validation --- src/components/aside/AsideNews.tsx | 4 +-- src/components/header/SubNav.tsx | 39 ++++++++++++++++-------------- src/components/news/News.tsx | 4 +-- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/components/aside/AsideNews.tsx b/src/components/aside/AsideNews.tsx index 14e1a29..7cd589a 100644 --- a/src/components/aside/AsideNews.tsx +++ b/src/components/aside/AsideNews.tsx @@ -33,9 +33,7 @@ const AsideNews = ({ title, date, img, category, link }: Props) => { - -

{title}

- +

{title}

diff --git a/src/components/header/SubNav.tsx b/src/components/header/SubNav.tsx index 26ec229..c4c37fb 100644 --- a/src/components/header/SubNav.tsx +++ b/src/components/header/SubNav.tsx @@ -1,30 +1,30 @@ // Modules -import { useLocation } from 'react-router-dom'; -import { v4 as uuidv4 } from 'uuid'; -import { useDispatch, useSelector } from 'react-redux'; -import { useEffect, useState } from 'react'; +import { useLocation } from "react-router-dom"; +import { v4 as uuidv4 } from "uuid"; +import { useDispatch, useSelector } from "react-redux"; +import { useEffect, useState } from "react"; // Types -import { RootState } from '../../types/store.types'; -import { ICategoriesData } from '../../types/data.types'; +import { RootState } from "../../types/store.types"; +import { ICategoriesData } from "../../types/data.types"; // Actions -import { setActiveLink } from '../../actions/setActiveLink.action'; +import { setActiveLink } from "../../actions/setActiveLink.action"; // Api -import { Api } from '../../api/Api'; -import { url } from '../../url'; +import { Api } from "../../api/Api"; +import { url } from "../../url"; // Components -import Loader from '../global/Loader'; -import SubNavLi from './SubNavLi'; +import Loader from "../global/Loader"; +import SubNavLi from "./SubNavLi"; const SubNav = () => { - const activeLink = useSelector( - (state) => state.activeLink.active, + const activeLink = useSelector( + (state) => state.activeLink.active ); - const language = useSelector( - (state) => state.language.title, + const language = useSelector( + (state) => state.language.title ); const dispatch = useDispatch(); @@ -36,7 +36,7 @@ const SubNav = () => { const [data, setData] = useState(); // Api - const api = new Api(url + '/categories'); + const api = new Api(url + "/categories"); useEffect(() => { api.get(data, setData); @@ -44,7 +44,10 @@ const SubNav = () => { const location = useLocation(); useEffect(() => { - if (!location.pathname.includes('category')) return; + if (!location.pathname.includes("category")) { + onClickLink(0); + return; + } const category = location.pathname[location.pathname.length - 1]; onClickLink(parseInt(category)); }, [location]); @@ -57,7 +60,7 @@ const SubNav = () => { <> diff --git a/src/components/news/News.tsx b/src/components/news/News.tsx index ac3b204..d5d97c9 100644 --- a/src/components/news/News.tsx +++ b/src/components/news/News.tsx @@ -31,9 +31,7 @@ const News = ({ id, title, text, categories, date, img }: Props) => {
- -

{title}

- +

{title}

{categories.map((category) => {