Search refactor #11

Merged
innocuous-symmetry merged 5 commits from search-refactor into master 2022-02-06 17:10:47 +00:00
3 changed files with 16 additions and 14 deletions
Showing only changes of commit 9d872e9170 - Show all commits

View File

@@ -97,7 +97,7 @@
.sidebar {
display: flex;
flex-direction: column;
width: 12rem;
width: 13.5rem;
position: fixed;
background-color: black;
color: white;

View File

@@ -20,6 +20,14 @@
margin: 0.8rem 0;
}
.individual-sub button {
margin-right: 1rem;
}
.individual-sub label {
text-align: right;
}
.search-sub-input {
margin-top: 2rem;
}

View File

@@ -1,23 +1,17 @@
import React, { useState } from "react";
// import { useDispatch } from "react-redux";
// import { updateSubVisibility } from "../reddit/redditSlice";
import React, { useEffect, useRef, useState } from "react";
import { useDispatch } from "react-redux";
import { updateSubVisibility } from "../reddit/redditSlice";
export default function SidebarItem({sub}) {
const [visible, setVisible] = useState('hide'); // dispatch will be used to dispatch updateSubVisibility on change in state
// const dispatch = useDispatch(); // this will likely be within a useEffect hook
const dispatch = useDispatch();
const handleClick = () => {
if (visible === 'hide') {
setVisible('show');
} else if (visible === 'show') {
setVisible('hide');
}
const handleClick = () => {
dispatch(updateSubVisibility(sub));
}
return (
<div className="individual-sub">
{/* <input type="checkbox" id={sub} checked={checked} onChange={handleClick}></input> */}
<button id={sub} onClick={handleClick}>{visible}</button>
<button id={sub} onClick={handleClick}>toggle</button>
<label id={sub}>{sub}</label>
</div>
);