Skip to content

Instantly share code, notes, and snippets.

View SunnyChopper's full-sized avatar

Sunny Singh SunnyChopper

View GitHub Profile
@SunnyChopper
SunnyChopper / EmployeeSearchContainer.js
Last active July 3, 2021 23:32
Employee Container without `useMemo`
import React, { useEffect, useState } from 'react';
import { fetchEmployees } from '../api/employees';
const EmployeeSearchContainer = (props) => {
const [selectedEmployee, setSelectedEmployee] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const [searchText, setSearchText] = useState('');
const [employees, setEmployees] = useState([]);
@SunnyChopper
SunnyChopper / EmployeeSearchContainer.js
Created July 4, 2021 00:27
Employee Container with `useMemo`
import React, { useEffect, useState, useMemo } from 'react';
import { fetchEmployees } from '../api/employees';
const EmployeeSearchContainer = (props) => {
const [selectedEmployee, setSelectedEmployee] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const [searchText, setSearchText] = useState('');
const [employees, setEmployees] = useState([]);
@SunnyChopper
SunnyChopper / votingPollSlice.js
Created January 18, 2022 01:30
Setting up a Slice with RTK
import { createSlice } from '@reduxjs/toolkit';
// Make an initial state for Redux
const initialVotingPollSlice = {
votedPollIds: [],
canVote: false,
currentVote: null
};
// Create a slice using RTK