Skip to content

Instantly share code, notes, and snippets.

View OnurGvnc's full-sized avatar
🎯
Focusing

Onur Guvenc OnurGvnc

🎯
Focusing
View GitHub Profile
@bfollington
bfollington / App.tsx
Last active April 29, 2022 07:20
useReducer + @reduxjs/toolkit
import React, { useReducer } from "react";
import { messages, initialMessagesState } from "./slices/messages";
const App: React.FC = () => {
const [messageList, dispatch] = useReducer(
messages.reducer,
initialMessagesState
);
return (
@screeny05
screeny05 / index.ts
Last active October 21, 2021 19:16
Native File System Typescript Typings – https://wicg.github.io/native-file-system/
declare global {
enum ChooseFileSystemEntriesType {
'open-file',
'save-file',
'open-directory'
}
interface ChooseFileSystemEntriesOptionsAccepts {
description?: string;
mimeTypes?: string;
@tannerlinsley
tannerlinsley / README.md
Last active April 12, 2024 17:04
Replacing Create React App with the Next.js CLI

Replacing Create React App with the Next.js CLI

How dare you make a jab at Create React App!?

Firstly, Create React App is good. But it's a very rigid CLI, primarily designed for projects that require very little to no configuration. This makes it great for beginners and simple projects but unfortunately, this means that it's pretty non-extensible. Despite the involvement from big names and a ton of great devs, it has left me wanting a much better developer experience with a lot more polish when it comes to hot reloading, babel configuration, webpack configuration, etc. It's definitely simple and good, but not amazing.

Now, compare that experience to Next.js which for starters has a much larger team behind it provided by a world-class company (Vercel) who are all financially dedicated to making it the best DX you could imagine to build any React application. Next.js is the 💣-diggity. It has amazing docs, great support, can grow with your requirements into SSR or static site generation, etc.

So why

@kyleshevlin
kyleshevlin / asPropFacade.js
Last active January 23, 2021 10:51
`as` prop and the facade pattern
// Sometimes you'll have a component that you want to allow the consumer
// to render a different HTML element for semantic purposes. Use an `as`
// prop and a facade pattern to make it happen.
export function CallToAction({as = 'button', ...props}) {
return <CallToActionFacade as={as} {...props} />
}
function CallToActionFacade({ as, ...props }) {
switch (as) {
@kyleshevlin
kyleshevlin / memoizedHandlers.js
Created January 22, 2021 00:26
Using React.useMemo to create a `handlers` object
// One of my new favorite React Hook patternms is to create handler
// functions for a custom hook using `React.useMemo` instead of
// `React.useCallback`, like so:
function useBool(initialState = false) {
const [state, setState] = React.useState(initialState)
// Instead of individual React.useCallbacks gathered into an object
// Let's memoize the whole object. Then, we can destructure the
// methods we need in our consuming component.