Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

8664 bites

Page 12

React Native1 min read

Button vs TouchableOpacity vs Pressable

Button is minimal and platform-styled with limited customization; TouchableOpacity wraps children with an opacity fade; Pressable is the modern, flexible primitive exposing rich press states.

React Native1 min read

Controlled TextInput with value and onChangeText

Store input text in state, bind value to that state, and update state in onChangeText so React is the single source of truth.

React Native1 min read

How StyleSheet.create reduces styling overhead

StyleSheet styles are created once with stable references, so identical renders skip reallocation and reduce diffing and serialization work; inline literals allocate new objects each render…

React Native1 min read

Why Text inherits styles but View does not

Nested Text inherits text styles because it maps to platform attributed-text rendering, while Views are independent layout boxes with no style cascade.

React Native1 min read

Circular View with centered text

Set equal width and height, borderRadius to half that, then justifyContent and alignItems center to place the Text in the middle.

React Native1 min read

Using position absolute in React Native

Absolute removes a view from flex flow and positions it relative to its nearest positioned ancestor using top, left, right, bottom; ideal for overlays and badges.

React Native1 min read

alignItems vs justifyContent in flexbox

JustifyContent aligns along the main axis, alignItems aligns along the cross axis; with column direction main is vertical and cross is horizontal.

React Native1 min read

Default flexDirection and header-content-footer layout

Default flexDirection is column, unlike web's row; give the root flex 1, fixed heights to header and footer, and flex 1 to a scrollable middle.

React Native1 min read

View vs Text and nesting rules

View is a flexbox layout container; Text renders and lays out text with inheritance. Text nests inside Text and inherits style; View inside Text is constrained and discouraged.

React Native1 min read

Inline styles vs StyleSheet.create

Styles are JS objects passed to the style prop; StyleSheet.create registers styles once for stable references and validation, while inline objects recreate on each render.

React Native1 min read

Building a native module from scratch

Write a native module class with exported methods or constants, register it via a package, then expose a typed JS wrapper.

React Native1 min read

Improving React Native startup time

Enable Hermes for fast bytecode startup, shrink and lazy-load the JS bundle via inline requires and RAM bundles, and defer non-critical native init.

React Native1 min read

Expo managed workflow vs bare React Native

Expo gives fast setup, OTA updates, managed builds, and prebuilt APIs; bare gives full native control and arbitrary native modules.

React Native1 min read

Fabric Native Components

Fabric Native Components are host platform views exposed to React under the New Architecture. They use JSI and a C++ rendering core so the shadow tree, layout, and view updates run synchronously without the legacy async bridge, reducing latency and tearing.

Python & FastAPI2 min read

Choosing Uvicorn worker count in production

Workers exist to use multiple CPU cores past the GIL; a common starting point ties count to cores, then you tune by load testing, balancing CPU and memory (each worker is a full copy) against connection-pool…

Python & FastAPI2 min read

Reading the full response body in middleware

Responses stream as multiple body messages and headers go first, so you cannot add a header after seeing the body; you must buffer all chunks, compute the hash, set the header, then resend.

Python & FastAPI2 min read

OAuth2 social login with your own JWT

A login endpoint redirects to the provider with a state param, a callback exchanges the code for the provider token, you fetch the user profile, upsert the local user, then mint your own JWT.

Python & FastAPI2 min read

selectinload vs joinedload for eager loading

Use eager loading options to avoid lazy N+1; joinedload uses a single JOIN (good for many-to-one) but can fan out rows on collections; selectinload issues a second IN query (better for one-to-many).

Python & FastAPI1 min read

Feature-based vs layer-based project structure

Layer-based groups by technical role and is simple early but scatters a feature across folders; feature-based groups by domain, improving cohesion and ownership at the cost of some duplication and…

Python & FastAPI1 min read

Streaming large file downloads efficiently

Use StreamingResponse with a generator that yields chunks (or FileResponse for an on-disk file), set media_type and a Content-Disposition header, so memory stays flat regardless of file size.