Skip to content

Instantly share code, notes, and snippets.

View roni5's full-sized avatar
💭
Typescript, Flutter , Python

Roni roni5

💭
Typescript, Flutter , Python
View GitHub Profile
import { useFetcher } from "@remix-run/react";
import { useCallback, useMemo } from "react";
export function useRevalidator() {
let fetcher = useFetcher();
let revalidate = useCallback(
() => {
fetcher.submit(null, { action: "/", method: "post" });
},
import {
Box,
IconButton,
IconButtonProps,
Tooltip,
useClipboard,
} from "@chakra-ui/react";
import React from "react";
import { BiCopy as CopyIcon, BiCheck as CopiedIcon } from "react-icons/bi";
import {
Box,
IconButton,
IconButtonProps,
Tooltip,
useClipboard,
} from "@chakra-ui/react";
import React from "react";
import { BiCopy as CopyIcon, BiCheck as CopiedIcon } from "react-icons/bi";
@roni5
roni5 / typeguard_in_typescript.ts
Created March 25, 2023 15:42 — forked from javierlopezdeancos/typeguard_in_typescript.ts
Typeguard in typescript #typescript
interface UserInterface {
id: number;
firstName: string;
lastName: string;
gender: string;
avatar: string;
age: number;
}
interface AdminUserInterface extends UserInterface {
function App() {
return (
<Routes>
<Route path="/" element={<Root />}>
<Route index element={<Index />} />
<Route path="projects" element={<Projects />} />
</Route>
</Routes>
);
}
// src/mocks/handlers.js
import { rest } from "msw";
export const handlers = [
// Handles a POST request
rest.post("https://fancy-app.com/postToThisEndpoint", (req, res, ctx) => {
return res(
// Respond with a 200 status code
ctx.status(200)
);
import type { V2_HtmlMetaDescriptor, V2_MetaFunction } from "@remix-run/node";
export const mergeMeta = (
overrideFn: V2_MetaFunction,
appendFn?: V2_MetaFunction,
): V2_MetaFunction => {
return arg => {
// get meta from parent routes
let mergedMeta = arg.matches.reduce((acc, match) => {
return acc.concat(match.meta || []);
@roni5
roni5 / WhyReact.md
Created September 23, 2022 15:16 — forked from sebmarkbage/WhyReact.md
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

@roni5
roni5 / gcp_deploy.md
Created September 12, 2022 17:30 — forked from phattv/gcp_deploy.md
How to use Docker to deploy an image to Google Cloud Platform
// hard, buggy, incomplete, slower
<button
onClick={async () => {
setLoading(true);
let result = await updateProject({
status: "active"
});
setLoading(false);
setResult(result);
}}