React

816 readers
1 users here now

A community for discussing anything related to the React UI framework and it's ecosystem.

https://react.dev/

Wormhole

[email protected]

Icon base by Skoll under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
1
2
3
4
 
 

Hi there,

I have written an article on implementing server-side caching that ensures your app stays fast as you scale.

I’ve used ExpressJS for the API server, and React for the frontend.

Hope this helps someone!

5
 
 

I stumbled upon this project on GitHub and figured it might be of interest to some people here

6
7
8
 
 

I have a custom hook that I'm working on to make a fetch request to an api, and it is causing infinite re-renders. I'm struggling a bit to understand how the various parts of my application fit together -- in particular, my store (zustand) is using a middleware (immer) for immutable state, and I'm not certain why its drafting system isn't protecting me from changes in object identity. What tools can I use to try to track down what I've gotten wrong? I can't really leave the web page open very long because I'm making 1000s of requests per minute to the api I'm working against, so the Chrome dev tools are out, and the static analysis tools I set up (typescript and eslint) haven't identified any errors, like missing a dependency from the useEffect hook dependency array.

9
10
11
 
 

Firereact is hooks, component and utilities library for Firebase and React.

Features

  • Very lightweight, unpacked size when unpacked, npm min bundle size when minified, npm minzip bundle size when minified+gzipped
  • Supports Auth, Firestore, Functions, Providers and Storage.
  • Provides hooks such as useUser for Auth or useDocument for Firestore, which can listen to realtime changes as well
  • Provides custom components such as <FirestoreDocument /> or <StorageDownloadLink /> to keep the logic simple and/or avoid unnecessary rerendering
  • Provides Providers such as FirebaseSuiteProvider, FirebaseAuthProvider or FirestoreProvider to access Firebase service instances anywhere in the component tree without relying on global variables or prop-drilling
  • Comprehensive documentation
12
13
 
 

I use React Helmet. I wanted to inject social meta tags in some of the pages. In order to DRY, I wanted to define these social meta tags as a separate component, which looks as below:

type SocialMetaProps = {
  title: string,
  description: string,
}

const SocialMeta = ({ title, description }: SocialMetaProps) => {
  return (
    <>
      <meta property="og:title" content={title} />
      <meta property="og:description" content={description} />
      <meta property="og:url" content={window.location.href} />

      <meta property="twitter:title" content={title} />
      <meta property="twitter:description" content={description} />
      <meta property="twitter:url" content={window.location.href} />
    </>
  )
}

export default SocialMeta

...which looks as such when I use it in a page:

<Helmet>
  <title>{resource.title}</title>
  <SocialMeta title={resource.title} description={resource.shortDescription} />
</Helmet>

The problem with that is that SocialMeta component does not render anything. I can confirm it by firing up browser console and doing document.head.getElementsByTagName("meta"). However, if I do it as below:

<Helmet>
  <title>{resource.title}</title>
  
  <meta property="og:title" content={resource.title} />
  <meta property="og:description" content={resource.shortDescription} />
  <meta property="og:url" content={window.location.href} />

  <meta property="twitter:title" content={resource.title} />
  <meta property="twitter:description" content={resource.shortDescription} />
  <meta property="twitter:url" content={window.location.href} />
</Helmet>

...it naturally renders the tags.

My best guess is that Helmet does not unpack <></>. Is there a way to render a custom component inside Helmet component?

Thanks in advance.


Environment

  • Vite
  • Typescript
  • React ^18.2.0
  • Helmet ^6.1.0
  • React Router (DOM) ^6.20.1 (if relevant)
14
8
Why React Re-Renders (www.joshwcomeau.com)
submitted 5 months ago by [email protected] to c/[email protected]
15
 
 

Hello there,

I'm moving from the Angular world to React and I'm looking for websites, Lemmy communities and Mastodon profiles to follow to keep up with the latest React news and best practices.

Ideally I would like resources similar to Ninja Squad's blog, Angular's blog or /r/Angular2. I'm already following this community as well as Josh W Comeau's blog.

Thanks in advance!

16
17
18
 
 

Really looking forward to this!

19
20
21
22
23
24
0
Test (test)
submitted 7 months ago* (last edited 7 months ago) by [email protected] to c/[email protected]
 
 

Should be deleted, if not let me know

25
14
submitted 8 months ago* (last edited 8 months ago) by aeharding to c/[email protected]
 
 

I started using Virtua for Voyager and I'm really impressed! It has a dead simple API (wrap existing .map with VList component), avoids rerendering items on scroll like other solutions, doesn't glitch on iOS devices with unknown height items like many other libraries, super small footprint. The author is also very responsive. Thought I'd share!

https://github.com/inokawa/virtua

view more: next ›