restored video function, app renders without crashing #16

Closed
innocuous-symmetry wants to merge 6 commits from restored-function into master
4 changed files with 1 additions and 72 deletions
Showing only changes of commit 75bb919d4a - Show all commits

View File

@@ -1,19 +0,0 @@
import React from 'react';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { store } from './app/store';
import App from './App';
test('renders a title', () => {
const { getByText } = render(
<Provider store={store}>
<App />
</Provider>
);
expect(getAllByText(/cat/)).toBeInTheDocument();
});
test('store is not empty or falsy', () => {
expect(store).not.toBeNull();
})

View File

@@ -28,6 +28,7 @@
img, video {
max-height: 45rem;
max-width: 75%;
object-fit: contain;
}

View File

@@ -1,53 +0,0 @@
import React, { useState, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { searchByActive, /* selectSearchResults */ } from '../posts/postsSlice';
import { selectActive, /* selectAllSubs */ } from "../reddit/redditSlice";
export default function SearchBar() {
const dispatch = useDispatch();
// const selectedSubs = useSelector(selectAllSubs);
const activeSubs = useSelector(selectActive);
const [term, setTerm] = useState('');
const [results, setResults] = useState(null);
// const searchData = useSelector(selectSearchResults);
const handleChange = (e) => {
e.preventDefault();
setTerm(e.target.value);
}
const handleSubmit = () => {
if (term && activeSubs) {
let extracted = [];
for (let sub in activeSubs) {
extracted.push(sub);
}
console.log(extracted);
let mapped = extracted.map((sub) => dispatch(searchByActive({sub, term})));
Promise.all([...mapped]).then((data) => setResults(data));
}
}
useEffect(() => {
let active = true;
if (results && active) {
console.log(results);
}
return () => {
active = false;
}
}, [results, activeSubs]);
return (
<>
<input type="text" className="nav-searchbar" placeholder="Search posts" value={term ? term : ''} onChange={handleChange} />
<input type="submit" onClick={handleSubmit}></input>
</>
);
}