Skip to content

Instantly share code, notes, and snippets.

const Parent = () => {
const [showParams, setShowParams] = useState(true);
const [results, setResults] = useState({})
const [params, setParams] = useState({});
const toggleShowParams = () => {
setShowParams(!showParams);
};
@mlghr
mlghr / .js
Last active May 4, 2025 17:51
Timelines not populating correctly
const Parent = () => {
const [dialogOpen, setDialogOpen] = useState(false);
const [showParams, setShowParams] = useState(true);
const [results, setResults] = useState({})
const [paramsHaveChanged, setParamsHaveChanged] = useState(false);
const [params, setParams] = useState({});
const toggleShowParams = () => {
setShowParams(!showParams);
};
@mlghr
mlghr / .tsx
Last active February 18, 2023 21:33
Change button color
// this is my function that I pass to each button in my form -
// function to change color on click
const toggleButtonColor = (event: { target: HTMLInputElement }) => {
event.target.getAttribute('colorScheme') === INITIAL_BUTTON_COLOR
? event.target.setAttribute('colorScheme', 'blue')
: event.target.setAttribute('colorScheme', INITIAL_BUTTON_COLOR)
}
// form gets the function
module.exports = {
/**
* Sends an email to the recipient in the body of the request
*/
send: async (ctx) => {
const body = ctx.request.body
const sendTo = body.email
strapi.log.debug(`Trying to send an email to ${sendTo}`)
try {
@mlghr
mlghr / .js
Last active March 16, 2022 14:59
App.js
import React, { useState, useEffect } from 'react';
import './App.css';
import { BrowserRouter, useHistory } from 'react-router-dom';
import Navigation from './routes-nav/Navigation';
import Footer from './components/Footer';
import Routes from './routes-nav/Routes';
import BannerBar from './components/BannerBar';
import UserContext from './auth/UserContext';
@mlghr
mlghr / minUniqueSum.txt
Created February 17, 2021 22:48
minUniqueSum solution
def minUniqueSum(arr):
if len(arr) == 0:
return arr
arr.sort()
sum = 0
i = 1
prev = arr[0]
curr = arr[i]
@mlghr
mlghr / meander.gist
Created February 17, 2021 20:03
solution for Meandering Array problem in Python
def meander(unsorted):
unsorted.sort()
meander_arr = []
small = 0
large = -1
while(unsorted[small] != unsorted[large]):
meander_arr.append(unsorted[large])
meander_arr.append(unsorted[small])
small = small + 1
large = large - 1
import { useRef, useState, useEffect } from "react";
/** Custom hook for managing "flash" messages.
*
* This adds an item in state, `active`, which can be controlled by the
* component as desired. The component would typically `setActive(true)`
* to start displaying the message, and after `timeInMsec`, active would
* go back to false, which would typically stop showing the message.
*
* In the component::
@mlghr
mlghr / gist:907e9e87929a1de75c2ed5354242d67c
Created January 18, 2021 04:10
React learning (lifecycle methods)
function MatchCard() {
const [isLoading, setIsLoading] = useState(false);
const [isMatch, setIsMatch] = useState(false);
const [user, setUser] = useState([]);
/** Generates new user from randomuser.me API */
async function getRandomUser() {
try {
setIsLoading(true);