Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [jsx]

JSX is an open source programming language, or an AltJS with classes and static types. The source code is compiled into JavaScript which is highly optimized.

2
votes
0answers
18 views

Access object in an custom attribute efficiently

Im trying to access the attribute directly in the parent component, that why Im using the ref method. here an example of why Im trying to achieve: https://...
1
vote
1answer
21 views

Different class name based on condition in React

I have a very simple component, which should be styled differently based on the passed condition. I wonder if there is a better approach to refactor this piece of code? ...
3
votes
1answer
24 views

Babel code in React component to display tasks

I'm trying to think of ways to clean up this component in my app so it looks more readable to other devs. This is the best I came up with so far. It's not that bad, but I think it could be a lot ...
3
votes
0answers
38 views

Reusable grid layout for React.js

I have taken someone else's HTML and CSS code for grid layouts and reactified it. When converting the code to React, I tried to make it as simpler. I would like to learn from community, if any ...
1
vote
0answers
65 views

Implementation of Private Route with Auth using react-router and Context API

I'm trying to implement safe routes and checking if the user is authorized using only Context API. I'm also trying to avoid that the user can see a PrivateRoute, ...
1
vote
0answers
271 views

React Hooks conditional in useEffect

I'm starting using hooks, and I have a specific scenario that I'm thinking useEffectis appropriate for. Essentially what I'm doing is: I have some ...
2
votes
0answers
21 views

Grouping and displaying people by political demographics

I have a function that sorts and groups items inside an array and then adds a corresponding jsx element to the page. I've already refactored it from 100 lines of code to 44, but I'm sure that its ...
2
votes
1answer
66 views

React board game app

I was told to code a board game app using React for a job interview. They told me they chose other candidates to move forward with, so I was wondering on what I could improve. The full code can be ...
1
vote
0answers
22 views

Conditionally show various video panels

The use case that this code tries to meet is There will be an interview session where the video calling is done between two participants, interviewer(ER) and ...
1
vote
0answers
196 views

Stateless tooltip component using React hooks and ref

What I'm trying to create is a generic tooltip component that I can use anywhere. I decided on a stateless component and the use of hooks and ref. Explanation 💡 Hook, because I wanted to have a ...
0
votes
0answers
21 views

70L React Router

This is a small router for a React application. Router changes the displayed content depending on the current location. Link changes the location when the user clicks on it. navigate changes the ...
0
votes
0answers
33 views

Self-removing modal using react portal

The goal was to use React.createPortal() to render a modal component inside a <div> other than the application root. This ...
1
vote
0answers
13 views

ReactJS code that allows at most one profile pic to be selected

I am making a profile picture selection screen, basically you select a picture pic1, if another picture pic2 is selected, then we cancel the highlight of pic2 and highlight pic1. Here is my code right ...
1
vote
0answers
32 views

React context API design pattern

I created a boilerplate from react-boilerplate. I have removed redux and immutable for use context API and ...
0
votes
0answers
57 views

BMI calculator with React Hooks

I wrote this Body-Mass Index calculator as part of a test. I'm new to React Hooks so I'm not sure whether this is good practice or not. When it comes to the component implementation and the tests, I'm ...
1
vote
1answer
66 views

React For loop component

This is my React component for looping a component i.e. I don't want to use MAP or FOREACH in React Component's HTML. ...
2
votes
0answers
144 views

Tic-Tac-Toe with React hooks

I have found similar posts which has some optimizations on Winning-checking logic: React Tic Tac Toe My primary focus for this post is about hook setters being ...
1
vote
1answer
109 views

React table with JSON

I'm pretty new to React and I was working on some JSON data. Now I just to understand basic concepts, so I wrote this little component, but in my eyes it's not efficient. ...
1
vote
1answer
64 views

CSS and React.js for a basic navigation drawer

I am trying to optimize my navigation drawer code. I have tried and followed the BEM naming convention for my CSS although I would like it reviewed with respect to the best practices being followed. ...
2
votes
0answers
49 views

Textbox validation component

My intention is to have a component that serves as a textbox wrapper and able to set the error state, error message, and allow the parent to pass a function that sets its local error as I did not see ...
1
vote
0answers
152 views

React Native app screen for booking appointments

I've been building a two-sided (both clients and service providers would use the app) appointment booking app. This is a screen from which a service provider can confirm their profile after having ...
1
vote
1answer
165 views

Recursive react.js navigation menu

I'm very new to React.js and have to start converting an entire website at my work. It's fun, but I'm hoping to get some feedback about how I tackled building this navigation component as I don't ...
2
votes
1answer
57 views

Validating Array before rendering

I am rendering a list from an array of objects. I want to check the correctness of the array before rendering. For that I am using typeof and null. In real situation the list comes from the API. Is ...
2
votes
0answers
75 views

ReactJS Typewriting animation

One of the dream idea to build typewriting in ReactJS. The code seems to be working, still there are something looks not that great in the code 😔 Looking for better solution (best practice) in the ...
1
vote
1answer
73 views

Using a public API to display data

It's a simple app that uses a public API to display data. It works as is, but I'm seeing a lot of spaghetti code that my limited experience can't fix on its own. ...
3
votes
2answers
62 views

Rendering plain text with paragraphs and line breaks as HTML

I have text inside a variable that I need to separate in paragraphs, and at the same time respect the manual breaklines. This is my code: ...
2
votes
1answer
681 views

How to set state of multiple properties in one event handler (React)

Pretty straight forwards really...I know that it's usually bad practice to repeat your code so I'm wondering how I could join handleAuthorChange() and handleContentChange() into one method. I guess it ...
3
votes
2answers
77 views

React-based weather app

I am an experienced developer but pretty new to React. I wanted to go on my own and build a simple little weather app that updates the image, tempature, and description of each day when you click on ...
1
vote
1answer
35 views

Create an Array of Objects for Patch Notes in React

I was looking to get some reviews of my code, so I can improve my writing. Functionally it works the exact way I want it to based on my patch notes .md file. I'm open to all suggestions for improving ...
0
votes
1answer
29 views

Header navigation with React

I'm new to React and started this project as a sandbox to experiment with it. I implemented a main page wich has a header and some content. The content is selected on the header. I'm wondering how it ...
3
votes
0answers
116 views

First React App: ToDo list

This is my first attempt at React and I don't want to pick up any bad habits for the long term. The code is adopted from a example app, but I have added a fair amount of new features. I.e. Clicking ...
1
vote
0answers
26 views

In React/Redux, fetch a list from a server and create a randomized subset with lifecycle methods

This is my first React/Redux project. I'm pulling down a list of Google Fonts, then displaying a list of 3 randomly selected ones. I want the list of random fonts to be populated automatically after ...
2
votes
1answer
78 views

Dice-rolling tool

I am an experienced programmer, but a complete beginner with React. My goal is to teach myself React. I've made a simple die-roller application. The application presents a drop-down, and the user can ...
1
vote
1answer
27 views

Navigation bar React component, with a “back” and a “close” variant

I am working on a component for a navigation bar. This navigation bar currently has two variations: a "back" version, and a "close" version. I have come up with three different implementations but I ...
3
votes
1answer
46 views

Hover on list items to change map marker styling

I'm struggling to make a React/JS map I have more efficient. Essentially, I have a list of cards, and then a map of markers. When I hover on one of the cards, it changes the styling of the marker. ...
0
votes
1answer
20 views

Transform a javascript object to an array based on value of each key in the original object

I have an object of ingredients to be added to a burger. Its structure is as follows: Input ...
1
vote
1answer
53 views

React component for Pai Gow game

TL;DR what should I do if I have too many methods in my parent component?? I'm making a card game (Pai Gow Tiles) using react and I am having trouble finding a way to format my parent component. I've ...
1
vote
0answers
448 views

React + Django (session) authentication

Is authentication implemented correctly? At the entry point to the app, which is App.js, query the Django server, which responds whether the current user is ...
1
vote
1answer
427 views

React container component to fetch paginated data for a stateless table component

TableContainer.js does the common task of fetching data and passing it to a lower component, Table.js, which is a stateless ...
2
votes
1answer
67 views

Wrote a floodfill visualizer in React

First time using React. Here is a demo: https://ostralyan.github.io/flood-fill/ Game Component ...
1
vote
1answer
24 views

Reacting to moods with icons

This is a class in my React app. This code works and displays an appropriate icon and question for every description. ...
0
votes
1answer
99 views

List with selectable and sortable elements

The code consists in making a list of elements sortable (with the drag on the right) and selectable (click on the text). However it seems a little too complex. https://codesandbox.io/s/434p397p74 ...
1
vote
1answer
86 views

Basic ReactJS Components routing

Recently I've started learning ReactJS and I do not look forward to making one Page website so I learned about react-router and this is my way of doing to it. App....
1
vote
1answer
130 views

React multi-select-like component with filter

I am new to react (and javascript in general) but am enjoying learning it. I have decided to make a little multiselect component which should work as follows: I start with my data in one list, when ...
2
votes
1answer
37 views

Request for improvements on a simple React app

I'm looking for a review of a recent project I finished for school. It is an app that functions like Twitter. It includes an Express server and Routes. Instead of using databases, it uses JSON files. ...
2
votes
1answer
38 views

Redux actions inside a container for a calculator

I used to import all the actions in the container's argument which looks messy (I put a comment below where I do it in that way). I want to know if there is a better approach when using actions with ...
2
votes
2answers
85 views

React clock component

I'm new to React.js and this code came from 30 Days of React - Day 7. However the given code example wasn't working so I rewrote it myself. My biggest issue here is how to make the component work ...
2
votes
0answers
25 views

Markdown Previewer app done in ReactJS

What do you think of my markdown previewer, which uses the marked library? I'm asking because I'm new to React. And also what do you think of app itself? Did I use React correctly and properly? HTML: ...
3
votes
0answers
65 views

Game of Life as a React app [closed]

I think the general functionality is there, but sometimes it looks a little slow/clunky when I try to run my app. Highlighting cells can be slow as it skips over some of the cells I hover over if my ...
1
vote
0answers
56 views

React form to add contacts to an app

I was recently building a form to add contacts to a play app I'm making and I finally got it to work. The problem is I'm not too happy with it. It's my first time building an application with React, ...