Navigates? | declarative? | Makes GET, triggers loader | Makes POST, triggers action | No requests |
---|---|---|---|---|
navigates | declarative | <Link to=""> <Form method="get"> |
<Form method="post"> |
<Link to="#..."> |
navigates | imperative | navigate() setSearchParams() |
submit() |
navigate("#") |
stays | declarative | <fetcher.Form method="get"> |
<fetcher.Form method="post"> |
(doesn't make sense) |
s |
import { z } from 'zod'; | |
import { getParams } from './params'; | |
const envSchema = z.object({ | |
NODE_ENV: z.string(), | |
DATABASE_URL: z.string().url(), | |
SESSION_SECRET: z.string(), | |
AUTH_SECRET: z.string(), | |
ENABLE_REGISTRATION: z.boolean().default(false), | |
SMTP_HOST: z.string(), |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'
instead ofconst foo = require('foo')
to import the package. You also need to put"type": "module"
in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)
from CommonJS instead ofrequire(…)
. - Stay on the existing version of the package until you can move to ESM.
import { ConfigInterface, useSWRInfinite } from 'swr' | |
import { useMemo, useCallback, useRef } from 'react' | |
import last from 'lodash.last' | |
import get from 'lodash.get' | |
type PageKeyMaker<Page, Key extends any[]> = ( | |
index: number, | |
previousPageData?: Page | |
/** | |
* Mutable ref object. Set this to `true` before the request and `false` afterwards if the request is fetching more. |
CREATE SEQUENCE public.global_id_seq; | |
ALTER SEQUENCE public.global_id_seq OWNER TO postgres; | |
CREATE OR REPLACE FUNCTION public.id_generator() | |
RETURNS bigint | |
LANGUAGE 'plpgsql' | |
AS $BODY$ | |
DECLARE | |
our_epoch bigint := 1314220021721; | |
seq_id bigint; |
<form> | |
<input type="text" name="cities[]" /> <!-- for arrays and objects. don't enumerate/propertize in markup. yes i just invented propertize --> | |
</form> |
async function getData(){ | |
const a = await someFunction().catch((error)=>console.log(error)); | |
const b = await someOtherFunction().catch((error)=>console.log(error)); | |
if(a && b ) console.log("some result") | |
} |
const obj = { a: 1, c: 3, b: 2 } | |
// Map from object. | |
const myMap = new Map(Object.entries(obj)) | |
// Map to Object. | |
// NOTE: Keys will be cast to strings by `.toString`, so any "complex" key like for example `[1, 2]` will become `1,2` | |
const newObj = [...myMap.entries()] | |
.reduce((acc, [key, value]) => (Object.assign(acc, { [key]: value })), {}) |
tl;dr I built a demo illustrating what it might look like to add async rendering to Facebook's commenting interface, while ensuring it appears on the screen simultaneous to the server-rendered story.
A key benefit of async rendering is that large updates don't block the main thread; instead, the work is spread out and performed during idle periods using cooperative scheduling.
But once you make something async, you introduce the possibility that things may appear on the screen at separate times. Especially when you're dealing with multiple UI frameworks, as is often the case at Facebook.
How do we solve this with React?
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c | |
index 16c3046..ca912ce 100644 | |
--- a/drivers/input/mouse/synaptics.c | |
+++ b/drivers/input/mouse/synaptics.c | |
@@ -173,6 +173,7 @@ static const char * const smbus_pnp_ids[] = { | |
"LEN0046", /* X250 */ | |
"LEN004a", /* W541 */ | |
"LEN200f", /* T450s */ | |
+ "LEN0073", /* X1 Carbon 5 (Elantech) */ | |
NULL |