Posts

Showing posts from April, 2024

react-router data router vs useSwr thoughts

We work on apps which use both useSwr and  react-router data router  Both useSwr and react-router DataRouter can both be used to build apps and  both provide fetching and caching updating, optimistic update support auto refreshing But both libraries are quite different to use and in their "sweet spots". react-router DataRouter  sweet spots app has multiple routes e.g. List, Edit, View, Create etc. multi route SPA has straightforward form data for Create, Edit etc. As in a page worth of data (not pages and pages of nested within nested data) progressive web support its opinionated: "classic web" submit form data, to actions which handle persistence routes have associated loader functions to get data  there is a learning curve and also some unlearning to do modelled on Remix which expects actions to be hosted on the server and receive form submissions useSwr sweet spots no routes e.g. one route SPA complex, multiform amounts of data, nested forms you 💜 hooks and wan

css box shadow instead of border

Borders take up space in web browser html When setting width/height in a component this can have unintended consequences: the size of the component is not as expected. The content area may be less. A cool solution is to use box-shadow instead of border e.g. 1 px border `box-shadow: inset 0px 0px 0px 1px blue` see good explanation here