supasate / connected-react-router

A Redux binding for React Router v4
MIT License
4.73k stars 593 forks source link

link button not working second when i added new maincategory, it is rendering same component intead of going path #615

Open dineshbhati61102 opened 1 year ago

dineshbhati61102 commented 1 year ago

import React, { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import LeftNav from './LeftNav' import { useDispatch, useSelector } from "react-redux" import { GetMaincategoryAction } from "../../Store/Actions/MaincategoryAction"

const AdminMaincategories = () => { const [Maicategories, setMaicategories] = useState([]); const dispatch = useDispatch(); const { data, error } = useSelector(state => state.MaincategoryStateData);

function getAPIData(){ dispatch(GetMaincategoryAction()) if(data.length) setMaicategories(data) }

useEffect(() => { getAPIData() }, [data.length])

return ( <>

Maincategories

Add New {error ?
{error}
: Array.isArray(Maicategories) && Maicategories.map((elem, index) => { return })}
ID Name Edit Delete
{elem._id} {elem.name} Update
</>

) }

export default AdminMaincategories