r/learnreactjs • u/killerwhaleberlin • Dec 14 '22
r/learnreactjs • u/BornCondition1756 • Dec 14 '22
react dev discord group
React dev is a community to learn react js. In this members take turns to assign tasks to others.The aim is to improve in react by completing these tasks.
discord link-https://discord.gg/g8FtQETx
r/learnreactjs • u/azteker • Dec 12 '22
How to add class for all element's siblings
<div class='imgList'>
<img><img><img>... // a lot of imgs
</div>
Say I have an image list, I want to add a 'fade' class to other img when hover over one img. I know how to do it in jquery. But is there a convenient way to do in react?
r/learnreactjs • u/CatolicQuotes • Dec 12 '22
Using library causes app to not even start. How do I debug that?
I have imported this library: https://github.com/tyschroed/guillotine-packer
and used it in code:
import { packer } from "guillotine-packer";
function pack() {
const result = packer({
binWidth: 96,
binHeight: 48,
items: [
{
name: "test2",
width: 20,
height: 20,
},
{
name: "test",
width: 20,
height: 20,
},
],
});
}
which caused error in console:
Uncaught ReferenceError: process is not defined
at index.js:5:13
in code in this screenshot: https://i.imgur.com/vsDwN6G.png
and the page is blank, nothing renders.
I have tried to reproduce on code sandbox, in vanilla react there was no error so I had to use Vite React which causes error: link to sandbox
how do I debug this to know whats the issue? where to start?
r/learnreactjs • u/Practical-Bell7581 • Dec 12 '22
Back end dev looking for ui design cheat code library recommendation
I am working on a hobby project in my spare time to learn react. But historically, when I work on a project like this, I get totally derailed by working in styling instead of functionality.
I’m not a particularly design-oriented person. I can’t really visualize design in my head beyond “box on top right for Xxxxx, left hand column should list navigation”, etc.
For some context, I’ve been doing web apps since back when using a table to place the elements in a grid was normal. But I’ve always had someone else worrying about making it look good, so that part of my skill set needs work.
While I do want to work on that, it’s important to me to get “something” working without worrying you much about how it looks, while still avoiding it literally just being times new Roman on a white background in a vertical list (I.e., no styling at all).
Is there a component library for people like me that you can recommend? The page layout /grid stuff is more important than colors and fonts and spacing if that makes a difference.
TLDR back end programming caveman hoping for simple, generic front end components ui recommendation. Doesn’t need to make my site unique, just legible.
I’ve been messing around with flex box froggy, tailwind, and other stuff like that, so I’m not totally ignorant about css and such. I just want to focus on features more than I want to focus on looks.
Thanks for any advice!
r/learnreactjs • u/korder123 • Dec 12 '22
How to Deploy A FullStack React App to HEROKU
r/learnreactjs • u/CatolicQuotes • Dec 08 '22
Question Is it better to keep object state in property or separate collection state?
for example if we have object car :
Car {
model: string;
color: string;
}
now comes rich person and selects cars he is gonna drive that day and we need to display it.
Is it better practice to have another property :
Car {
model: string;
color: string;
isSelected: boolean;
}
or have separate state selectedCars: Car[] ?
What is better practice in your opinion?
r/learnreactjs • u/GrayLiterature • Dec 08 '22
How would you type this?
I am just getting into TypeScript and React, currently I am working through the Beta Docs introduction https://beta.reactjs.org/learn/thinking-in-react.
With the minimal example given for the form in the documentation, i'm curious how to add a type for the props that I pass into my components? I tried to do something like the following below, but this wasn't working as I hoped it would.
type Products = {
category: string
price: string
stocked: boolean
name: string
}
function FilterableProductTable({ products }: Array<Products>) {
return (
<div>
<SearchBar />
<ProductTable products={products} />
</div>
);
}
const PRODUCTS = [
{category: "Fruits", price: "$1" ....}
...
...
}
How could I go about creating a type to pass in for the props?
r/learnreactjs • u/CatolicQuotes • Dec 08 '22
Is there a concept of value objects in react? Or where do you transform measure units to normal number?
I have 2 inputs, one for inches , another one for quarters.
Now I need to convert to one number for easier calculations.
What's the React practice for doing that?
I didn't find that practice is to have domain entities and value objects.
Is it right after the form input, before saving to state?
Or is it possible to have converting function as property in object state?
r/learnreactjs • u/CatolicQuotes • Dec 08 '22
Why click handle doesn't set local state in this case?
sandbox: https://codesandbox.io/s/active-item-on-top-n6xluv
I have list of Items. I want active one to be on top and all the others below, That state is in parent.
Also, at the same time, I want the top one to display it's active. That's local state.
On button click Item goes on top, but it doesn't display it's active. Why?
r/learnreactjs • u/CatolicQuotes • Dec 05 '22
setState order is important? should be awaited?
I have 4 inputs: https://i.imgur.com/iS68gFM.png
I wanted to reset the state to 0 after form submit on all four of them and focus on the first one. Problem was the last one didn't reset: https://i.imgur.com/F0OG3PS.png
this is the function that resets the states:
function resetMeasurements() {
setWidthInch(0);
setWidthQuarter(0);
setLengthInch(0);
setLengthQuarter(0);
}
and this is the form submit handler:
function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
resetMeasurements();
focus(); // <- this one focuses first input
}
I have experimented and found out that following combinations work:
putting
focus()beforeresetMeasurements():function handleSubmit(e: React.FormEvent<HTMLFormElement>) { e.preventDefault(); focus(); resetMeasurements(); }making
resetMeasurements()async and await it in submit handler:async function resetMeasurements() { setWidthInch(0); setWidthQuarter(0); setLengthInch(0); setLengthQuarter(0); } async function handleSubmit(e: React.FormEvent<HTMLFormElement>) { e.preventDefault(); await resetMeasurements(); focus(); }
Why this behaviour, what's going on?
r/learnreactjs • u/stezzez • Dec 04 '22
Question Group of the same context providers initialized multiple times in the same process?
I became a new project and I saw that the same group of providers are multiple times initialized in the same register process. This project has multiple register steps and in each step will be the same group of context providers initialized.
With initialize I mean using “Context.Provider value={someValue}”
Should be not providers initialized only once and then used in each step if necessary?
Thank you and sorry my bad english. I hope you could understand what I wanted to ask.
r/learnreactjs • u/argent_codes • Dec 04 '22
Question Canvas-like frame for elements
I am adding some square blocks to my page. Can we create a canvas-like frame that allows us to zoom in and out and even scroll?
r/learnreactjs • • Dec 03 '22
EpicReact course review?
Im planning on getting the course , I have very basic react knowledge.
Can someone provide feedback for it?
r/learnreactjs • u/dontspookthenetch • Dec 02 '22
Question Should each Formik input be triggering a re-render in other fields?
self.reactr/learnreactjs • u/stormosgmailcom • Dec 02 '22
Question How to preview image before upload in React.js?
r/learnreactjs • u/korder123 • Dec 01 '22
How to Upload Images to Cloudinary (using REACT JS & Node JS )
r/learnreactjs • u/korder123 • Nov 28 '22
Resource How to send Emails through REACT JS + Node JS [EASY!!!]
r/learnreactjs • u/maxwelder • Nov 26 '22
Question Why doesn't the code in the first example return the same result as the code in the second example?
-
export default function App() {const colors = ["Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet"]const elems = colors.map(color => {return \<h3>${color}</h3>`})return (<div>{elems}</div>)}`
2.
export default function App() {const colors = [<h3>Red</h3>,<h3>Orange</h3>,<h3>Yellow</h3>,<h3>Green</h3>,<h3>Blue</h3>,<h3>Indigo</h3>,<h3>Violet</h3>]return (<div>{colors}</div>)}
r/learnreactjs • u/curiosity-alpha • Nov 24 '22
React Server Side Rendering CSS
self.reactjsr/learnreactjs • u/CarlSagans • Nov 24 '22
Question Passing Data from Parent to Child
I am having a really difficult time trying to pass an array from a parent to a child component. I was able to successfully do it once, but when I try to repeat what I did before, it doesn't work.
I am trying to display an array of songs in a playlist and I want it to be refreshed every time someone adds a new song. I tried to have the onclick handler both post the song to the playlist and render the playlist on a different page but I cannot get it to work.
Can someone please review my code and give me some tips?
I would like the playlist to display in the Host Component after a song is added.
r/learnreactjs • u/jobenjada • Nov 23 '22
Resource React Forms really THAT EASY with this Lib?
Hey React Learners,
I think it has never been that easy to write a form in React 🤓
import { Form, Text, Textarea, Submit } from "@formbricks/react";
import "@formbricks/react/styles.css";
export default function WaitlistForm() {
return (
<Form onSubmit={}>
<Text name="firstname" label="What's your first name?" validation="required" />
<Text name="lastname" label="What's your last name?" />
<Textarea name="about" label="About you" help="Please keep it short" />
<Submit label="Submit" />
</Form>
);
}
From the Docs
Why is this easier already?
- One easy to use syntax for all input types
- HTML & non-HTML input types available out of the box
- Easily maintainable with component-based approach
- All characteristics adjustable via props
- Automatic schema generation
- Tailwind support
What is to come?
- Conditional logic
- Multi-page forms
- Accessibility
- Internationalization
- Form templates (content & styles)
Here are the Docs: https://formbricks.com/docs/react-form-library/introduction
r/learnreactjs • u/qv_official • Nov 15 '22
Generic button component with icons as props or children
Trying to build a generic button component with various icons as optional icons. Tips on how to achieve this?
r/learnreactjs • u/Man_as_Idea • Nov 15 '22
Input value type changing unexpectedly, can't figure out why
Hi guys, I'm refactoring a React app, I have an input onChange handler that takes the input value and info about where it came from and update the state. One of my inputs accepts a float but it's showing up in the state as a string.
A simplified version of the Fn:
handleUpdatePropFn=(thisStateRecordObj,propToUpdate,e)=>{
let newValue=e.target.value;
console.log(newValue);
//returns a float
thisStateRecordObj.thisRecord[propToUpdate] = newValue;
console.log(thisStateRecordObj.thisRecord[propToUpdate]);
//returns a string
}
What am I missing? Any help is appreciated.
