schizanon, to react

React? Oh, you mean my algebraic effect based UI rendering engine.

#react #reactjs #ui #webDev #javaScript #frontend #web

minioctt, to web Italian

https://octospacc.altervista.org/wp-content/uploads/2024/03/image-6-960x960.pngI side #projects non finiscono mai: ogni volta vengono quelle #idee che devono per forza essere stuzzicate… e puntualmente ciò che doveva essere un progettino di 1 giorno o 2 si protrae sempre più a lungo (e se non è tecnicamente già successo, sta nell’aria), e da #progetto collaterale diventa un nuovo progetto principale. E i #progetti precedenti? Beh… diventano a loro volta secondari! 😬️Praticamente, qualche settimana fa pensavo che avere una roba simile alla #fotocamera DSi (si, ormai quello è un chiodo fisso nel mio cervello, anche se mezzo arrugginito, e l’articolo non è ancora finito) ma open-source e per dispositivi #mobile moderni sarebbe figo, si può sviluppare qualcosa di versatile e potente… però non avevo personalmente iniziato nulla. Da però qualche giorno ho pensato di voler creare una piccola #webapp semplificata per fare questi memini con le scritte, e magari pure varie decorazioni (per il momento sto usando GIMP, che è molto tedioso). Stamattina ho pensato… “Perché non unire tutte e due le cose? Una versione molto basica riesco a farla in qualche giornata scarsa…”… si si 🤣️

Beh, non iniziamo al meglio, perché la prima metà giornata l’ho spesa a pensare “hm ok voglio qualcosa di multipiattaforma”, ma “il mio amore #web vanilla non va bene perché su telefoni più scrausi con camere marce non girerebbe bene, e quindi “vabbé quasi quasi provo #React Native”, solo che “ah mi sa che per avere un canvas di disegno su tutti i target di build devo usare questa libreria particolare”, peccato che “aiuto è un casino tra documentazione e dipendenze dell’ambiente non so cosa è più mentale”, e quindi “aspetta ma se usassi Godot?”, per poi scoprire che “mannaggia solo la versione iOS di Godot supporta le fotocamere (non ci godo[t])”, e allora “vabbé, Unity funzionerá”, e quindi via con la pazienza di installare un SDK LTS vecchio che supporta ancora Android KitKat (è stato lentissimo sulla mia VM cloud), peccato che poi “aiutoooo Unity è complicatissimo è impossibile fare qualsiasi cosa senza soffrire”, e anche se “magari ci sono altri engine #multipiattaforma che fanno al caso mio?”, purtroppo “no, non esiste un bel niente”. 😶‍🌫️️

E comunque alla fine mi sono convinta che in qualche modo questa cosa l’avrei fatta funzionare per forza su #ReactNative, che di tutte le probabili #soluzioni mi sembra ancora quella meno malata; per fortuna, #giochicchiando fino all’ora precedente (con non poca confusione), ho tirato su una base che mi dimostra all’atto pratico che ciò che mi serve è facilmente implementabile. Quindi, essendo la domanda del perché sempre esaurita da un “perché no?”, e risolto il dubbio del come, ora l’unica cosa che mi chiedo è il quanto… quanto #tempo e sudore prima di pubblicare la prima grezza build online? 💀️ (Ammesso che vada tutto liscio, perché sulla carta ora dovrebbe, ma nella pratica non ho ancora testato il funzionamento su Android, solo quello via browser…)

https://octospacc.altervista.org/2024/03/14/altri-progetti-senza-fine/

#fotocamera #giochicchiando #idee #mobile #multipiattaforma #progetti #progetto #projects #React #ReactNative #soluzioni #tempo #web #webapp

symfonystation, to javascript
@symfonystation@phpc.social avatar

Explore our article: Frontend Madness: SPAs, MPAs, PWAs, Decoupled, Hybrid, Monolithic, Libraries, Frameworks! WTF for your PHP backend? https://symfonystation.mobileatom.net/Frontend-Madness-JS-PHP-Backend

symfonystation, to javascript
@symfonystation@newsletter.mobileatom.net avatar

Explore our article: Frontend Madness: SPAs, MPAs, PWAs, Decoupled, Hybrid, Monolithic, Libraries, Frameworks! WTF for your PHP backend?

https://symfonystation.mobileatom.net/Frontend-Madness-JS-PHP-Backend

https://newsletter.mobileatom.net/frontend-madness/

joe, (edited ) to javascript

Earlier this week, we started looking at React and I figured that for today’s post, we should take a look at the https://react.dev/reference/react/useEffect and https://react.dev/reference/react/useMemo React Hooks. Hooks are functions that let you “hook into” React state and lifecycle features from function components. In yesterday’s post, we used https://codepen.io/steinbring/pen/GRLoGob/959ce699f499a7756cf6528eb3923f75. That is another React Hook. The useState Hook allows us to track state in a function component (not unlike how we used Pinia or Vuex with Vue.js).

The useEffect React hook lets you perform side effects in functional components, such as fetching data, subscribing to a service, or manually changing the DOM. It can be configured to run after every render or only when certain values change, by specifying dependencies in its second argument array. The useMemo React hook memoizes expensive calculations in your component, preventing them from being recomputed on every render unless specified dependencies change. This optimization technique can significantly improve performance in resource-intensive applications by caching computed values.

Let’s take a look at a quick useEffect, first. For the first demo, we will use useEffect and useState to tell the user what the current time is.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

Let’s walk through what we have going on here. The App() function is returning JSX containing <p>The current time is {currentTime}</p> and currentTime is defined by setCurrentTime. The code block useEffect(() => {}); executes whenever the state changes and can be used to do something like fetching data or talking to an authentication service. It also fires when the page first renders. So, what does that empty dependency array (,[]) do in useEffect(() => {},[]);? It makes sure that useEffect only runs one time instead of running whenever the state changes.

We can get a little crazier from here by incorporating the setInterval() method.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

In this example, it still runs useEffect(() => {},[]); only once (instead of whenever the state changes) but it uses setInterval() inside of useEffect to refresh the state once every 1000 milliseconds.

Let’s take a look at another example.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

In this one, we have three form elements: a number picker for “digits of pi”, a color picker for changing the background, and a read-only textarea field that shows the value of π to the precision specified in the “digits of pi” input. With no dependency array on useEffect(() => {});, whenever either “Digits of Pi” or the color picker change, useEffect is triggered. If you open the console and make a change, you can see how it is triggered once when you change the background color and twice when you change the digits of pi. Why? It does that because when you change the number of digits, it also changes the value of pi and you get one execution per state change.

So, how can we cut down on the number of executions? That is where useMemo() comes in. Let’s take a look at how it works.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

In this revision, instead of piValue having a state, it is “memoized” and the value of the variable only changes if the value of digits changes. In this version, we are also adding a dependency array to useEffect() so that it only executes if the value of color changes. Alternatively, you could also just have two . Let’s take a look at that.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

If you throw open your console and change the two input values, you will see that it is no longer triggering useEffect() twice when changing the number of digits.

Have any questions, comments, etc? Feel free to drop a comment, below.

https://jws.news/2024/exploring-useeffect-and-usememo-in-react/

#JavaScript #JSX #React #ReactHooks #VueJs

frankel, to javascript
@frankel@mastodon.top avatar
leanpub, to javascript
@leanpub@mastodon.social avatar

Learning Patterns by Lydia Hallie and Addy Osmani is free with a Leanpub Reader membership! Or you can buy it for $7.99! http://leanpub.com/learningpatterns #Javascript #WebDevelopment #SoftwareArchitecture #React #EventDrivenArchitecture

joe, (edited ) to javascript

Over the years, we have looked at jQuery, AngularJS, Rivets, and Vue.js. I figured that it was time to add React to the list. Facebook developed React for building user interfaces. The big difference between Vue and React is that React uses one-way binding whereas Vue uses two-way binding. With React, data flows downward from parent components to child components and to communicate data back up to the parent component, you would need to use a state management library like Redux. React is also a library where Vue.js is a framework, so React is closer to Rivets. You can run React with or without JSX and write it with or without a framework like Next.js.

Let’s look at how binding works in React and how it compares to Vue. In Vue, if we wanted to bind a form input to a text value, it would look like this

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

… and to do the same thing in React, it would look like this

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

You will notice that the React version uses the useState React Hook. Where the Vue version uses const inputText = ref('Blah Blah Blah'); for reactive state management, React uses const [inputText, setInputText] = React.useState('Blah Blah Blah'); to manage state. Also, Vue has two-way binding with the v-model directive but with React, the text updates when the state changes, but the state doesn’t automatically update when the input is edited. To deal with this, you manually handle updates to the input’s value via an onChange event. The developer is responsible for triggering state changes using the state updater functions in React. Another big difference is that Vue uses a template syntax that is closer to HTML while with React, JSX is used to define the component’s markup directly within JavaScript.

Let’s take a look at one more example

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

This example is very similar to what we had before but now there are child elements for setInputText(event.target.value)} /> and <TextDisplay text={inputText} />. This approach promotes code reusability. By encapsulating the input field and display logic into separate components, these pieces can easily be reused throughout the application or even in different projects, reducing duplication and fostering consistency. It is kind of the React way. Each component is responsible for its own functionality — InputForm manages the user input while TextDisplay is solely concerned with presenting text. This separation of concerns makes the codebase easier to navigate, understand, and debug as the application grows in complexity.

Have a question, comment, etc? Feel free to drop a comment.

https://jws.news/2024/it-is-time-to-play-with-react/

#JavaScript #JSX #React #VueJs

tanepiper, to react
@tanepiper@tane.codes avatar

I don't particularly like #React, up until a few weeks ago I hadn't touched it in years, but even with that I have to toot my own horn and say I'm writing some very performant and bug free apps with it (at least in my own code).

It sucks when you're forced to use someone else's design system that only supports React, but at least I've resigned myself to not fight it anymore.

f3rno64, to programming

Hi everyone,

I'm currently looking for a new job, something remote, full-time, or contract. A freelance opportunity would be welcome as well.

I'm a senior software engineer specializing in web app development, full-stack.

I primarily work with Node.JS, React, and TypeScript, along with Python if needed. I know several other languages as well.

If you know of any open positions or opportunities, please reach out!

This is my GitHub: https://github.com/f3rno64

And LinkedIn: https://www.linkedin.com/in/crismihalache/

#programming #tech #software #opensource #nodejs #typescript #react #python

nosherwan, to react
@nosherwan@fosstodon.org avatar

:react:
Remix.js

So I am slowly digesting the official tutorial for remix.js & I am finding it a pleasant experience.
They have tried to clean up the React meta framework experience.

I have used Next.js & vanilla react.js in the past, but I can see myself using Remix.js, especially now that Shopify have adopted it as well.

I am curious why are react people not interested in Remix.js?
This is a logical question I am not trying to attack someone's personal preference.


EvanMarie, to poop
indutny, (edited ) to random
@indutny@fosstodon.org avatar

Having some fun time playing with react-reconciler. Not sure if this idea will come to fruition, but I'm hoping to at least get it into a demo-able shape.

indutny,
@indutny@fosstodon.org avatar

Here's the end result: https://github.com/indutny/electron-ssr

I don't know if I have energy or desire to finish it given the limitations (I realized really late that you can't marshal ReactSyntheticEvent), but it was super fun!

The demo looks a bit plain, but all the fun stuff happens under the hood. The UI is translated to real DOM nodes in the renderer (UI process of Electron), but the state (callbacks, count) is actually managed by the main process (aka backend of Electron).

#electron #react

Demo of React rendering between Main and Renderer process n Electron.

indutny, (edited )
@indutny@fosstodon.org avatar

My extended goal with this exercise was to do something like Server-Side Rendering between Electron's Main and Renderer processes. For that to be complete I would need to introduce some sort of boundary class that would let me wrap the components on the server-side (main process), and let client-side (renderer process) actually hydrate them.

I might give it a go a bit later, but I'm quite satisfied with what I got so far!

indutny,
@indutny@fosstodon.org avatar

Aha! It was actually easier than I thought and I managed to do a simplified version that doesn't yet support syntactic sugar of 'use client’. Check this demo out!

The red area is pre-rendered in the main process (server), and the green one is a client component that lives in the renderer process (client). The most important bit is that the main process state (useState and such) is preserved on the refresh, while the renderer process starts afresh!

This is so fun 🤩

Electron React SSR demo

indutny,
@indutny@fosstodon.org avatar

Here is the component's source. As advertised the boundary between client/server components is a bit raw, but that can be polished away given further interest!

Source code:

If you like what I'm doing with this and think that I should keep it up - maybe encourage me a bit with stars and boosts? 🤗

#electron #react

[// Renderer component import { useState, useCallback } from 'react'; export default function Renderer(props) { const { count, addOne, removeOne } = props; const [local, setLocal] = useState(0); const addLocal = useCallback(() => { setLocal((n) => n + 1); }, []); const removeLocal = useCallback(() => { setLocal((n) => Math.max(0, n - 1)); }, []); const reload = useCallback(() => { window.location.reload(); }, []); return ( ### This runs in renderer process

Add globally Remove globally Add locally Remove locally {local + count > 5 ? ( You clicked so much

) : null} Global Count: {count}

Local Count: {local}

Reload Window

); }](https://cdn.fosstodon.org/media_attachments/files/112/070/309/288/395/372/original/ab50aace1d3b6b68.png)

drupler, to drupal
@drupler@bihar.social avatar

Ready to take your Drupal decoupling game to the next level?

Join us for a deep dive into leveraging Handlebars, a lightweight JavaScript templating tool, to create decoupled menus easily in decoupled, headless, or progressive decupled applications with Marcelo Vani.

In this session, we'll walk you through a live demonstration of implementing a decoupled Admin toolbar using Handlebars in three simple steps. Say goodbye to complex package management and compilation headaches – Handlebars streamline the process, making it accessible to developers of all skill levels.

Following this, we will have a project showcase and a story from a group of Suffolk local residents with various skills and enthusiasm. They have completed three innovative local history projects using Drupal with plenty of public involvement and praise from respected local historians and local history groups: StreetStroll, Our Fallen and SkyLine. Hear more from Joe Thompson about the importance of the projects and how Drupal has helped with these exciting and impactful projects.

RSVP at https://meetu.ps/e/MYXFR/8CQbT/i

Reserve your spot today and participate in this exciting event at The Children's Society in London on the 26th (Tuesday) for an engaging session packed with practical insights and an informative and actionable Drupal Meetup this March 2024!

#Drupal #Handlebars #Decoupled #DecoupledDrupal #WebDevelopment #JavaScript #PDA #NextJS #React #OpenSource #London #UnitedKingdom

sirber, to react
@sirber@fosstodon.org avatar

You need a Master Degree to use #react efficiently.

#WebDev #JavaScript

daishi, to reactjs
@daishi@fosstodon.org avatar

I just released use-context-selector v1.4.4,

found out it's the 50th version,

and found out it has 100 dependents!

#ReactJS #React #JavaScript #TypeScript #ReactHooks

FrontEndSheff, to Sheffield

We've announced our March 28th #Frontend #Sheffield event with:
🪣 @RichardOliver - Solving data fetching issues with #React
🎹 @yaxu - Contributor to @strudel / #Strudel the JavaScript-powered OpenSource algorithmic live music tool

🎟️ Tickets now available: https://www.meetup.com/front-end-sheffield/events/299457976/

joe, to random

I’m working on figuring out React as a long-time Vue developer. That #JSX syntax is a bit of a mind f#%k.

joe,

This is going to take some getting used to, also. 🤨

#React #DataBinding

leanpub, to javascript
@leanpub@mastodon.social avatar

The Road to React (The Bare Essentials) by Robin Wieruch is on sale on Leanpub! Its suggested price is $49.00; get it for $36.75 with this coupon: https://leanpub.com/sh/oBcPWGw2 #ComputerProgramming #Javascript #React #Html #Css #WebDevelopment #Education #ComputerScience

mobileatom, to react
@mobileatom@me.dm avatar

Enhancing Existing Gutenberg Blocks, A Step-by-Step Guide with React and WordPress.
https://micheal.dev/blog/enhancing-existing-gutenberg-blocks-a-step-by-step-guide-with-react-and-wordpress/ #Gutenberg #React #WordPress

alexelcu, to react
@alexelcu@social.alexn.org avatar

#Preact, the light alternative to #React, doesn't require a build process, as it's using:

‣ tagged templates, instead of JSX;
‣ JavaScript modules.

This is the future of #JavaScript:
https://preactjs.com/guide/v10/getting-started#no-build-tools-route

#noBuildTools #op

sarajw, (edited ) to random
@sarajw@front-end.social avatar

Are there any good tutorials on the Adobe React Aria component library?

Specifically on making an accessible fancy select-a-like that includes images and descriptive text, if such an article exists.

The docs seem good but I've ended up a little stuck anyway, and would appreciate something very step by step to just plough my way through.

Thank you!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • mdbf
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • megavids
  • GTA5RPClips
  • tacticalgear
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • ethstaker
  • anitta
  • provamag3
  • Leos
  • cisconetworking
  • lostlight
  • All magazines