News Articles r/reactjs

Mantine – React library with 60+ hooks and components and dark theme support

submitted by /u/binaryfor [link] [comments] Source: /r/reactjs

Cannot access errors object from backend in React.

******************** Frontend code : const Login = () => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [errors, setErrors] = useState({}); const navigate = useNavigate(); const handleSubmit = (event) => { event.preventDefault(); const userData = { email, password, errors }; axios .post("/loginUser", userData) .then(res => { localStorage.setItem('FBIdToken', `Bearer ${}`); navigate('/'); }) […]

Architecture for calendar booking app

Hi everybody, I'm currently building a website with Gatsby. The goal is to have a database of different people (doctors for example) and a calendar to book appointments with them. Also the users that book should create an account. My idea is to use auth0 for user management and mongodb to store the doctor data […]

Multiple files not disabled even after using property multiple = {false}

Please take a look at this codesandbox example: ​ If you see on Line #186 for Advanced uploader, the multiple property is set to false: ​ <div className="card"> <h5>Advanced</h5> <FileUpload multiple={false} name="demo[]" url="" onUpload={onUpload} accept="image/*" maxFileSize={1000000} emptyTemplate={ <p className="p-m-0">Drag and drop files to here to upload.</p> } /> So this won't allow me to […]

Extract text from scrollable element

Hi, I am not a web developer. My intent is to extract the data from a chat window. The window doesn't allow me to select all the chat messages. Below is the text I see when I am scrolling and the index number changes as I am scrolling. Any ideas how to extract the hidden […]

A few points concerning React/Typescript/Jest/Apollo/ReactTestingLibrary oddities.

submitted by /u/OldManWithAQuill [link] [comments] Source: /r/reactjs

My API requests are being sent in a loop and I’m not sure why

Hello, I'm fetching some data from a back end server and trying to display it in a component. I am currently facing a problem where the fetch request keeps being sent in a loop. In my component, I do the following to save the API response in state: export default function AssetManager(){ const [assetstate, setAssetstate] […]

I chose zustand over context api for my side project and my mentor is not happy about it. Am i doing the wrong here?

So I am currently building a web app using nextjs and have to make my user's data globally available as a state if he/she is authorised. So instead of using context api, I chose zustand because it needed less code and was easy to setup. Later, when I informed this to my mentor he said […]

Gatsby, how to lazy load on route?

Hey all I need to lazy load a page but not sure how to lazy load based on routing does anyone know how this works? Thanks! submitted by /u/plasmaSunflower [link] [comments] Source: /r/reactjs

How I can call two functions to promise for a function

const firstPromise = () => new Promise((resolve) => { setTimeout(resolve, 1000); }); const secondPromise = () => new Promise((resolve) => { setTimeout(resolve, 1000); }); function UserPage() { const [players, setPlayers] = useState < PlayerType[] > ([]); const [positions, setPositions] = useState < Position[] > ([]); const [firstLoading, setFirstLoading] = useState(true); const [secondLoading, setSecondLoading] = useState(true); […]

this.props.history.push(‘/’) isn’t redirecting me to the homepage. Does anyone know of a solution?

I've just posted the question on StackOverFlow and have been stuck on this for the past 3 hours. I am not sure what is causing this issue. submitted by /u/zRage4 [link] [comments] Source: /r/reactjs

I have this child component where you can submit a form, however, clicking submit will reload it

From the parent component. A user may click the button to show the form from the child component. const [isTrue, setIsTrue] = useState(false); <ButtonForm onClick={() => setIsTrue(true)}> Click for the Form </ButtonForm> {isTrue == true ? ( <Form data={entryData} items={items} names={names} /> ) : ( ></> )} The child component. The problem here is that, […]

Help about useEffect

Hi guys, I'm learning React, and i have a question about useEffect dependency. In the below code ( which i got from Max's React Course ) ​ useEffect(() => { sendRequest(quoteId); }, [quoteId, sendRequest]); So i've known that the callback function inside useEffect will re-execute when one of dependencies changes. But when will the function […]

Help with conditional rendering

Hey, I'm trying to render some stuff based on the pathname, the problem I'm having is that some of the pathnames have some differences: i.e. /:id/:option. How can I render a component for all paths with :id and any 'option'? I'm doing something like this for the conditional rendering: {pathname === `/${id}/directory` ? <PropertyNav /> […]

When to useMemo and useCallback

Example ​ export default function App() { const [step, setStep] = useState(1); const onIncrease = useCallback(() => setStep((prev) => prev + 1), []); const onDecrease = useCallback(() => setStep((prev) => prev – 1), []); const Content = useMemo(() => { switch (step) { case 1: return <div>Huge Step 1 component will be here</div>; case […]

How to put a create-react-app app into html with input variables?

So I made a complete widget/app using the create-react-app boiler plate. However, I need to implement this widget inside an html page. The widget's job is to render some data passed in by the html (like displaying and plotting the data). What's the simplest way to get a create react app app into an html […]

Question about form state control

I probably know enough about React to be dangerous, so I wanted to get some advice on an issue I frequently come across. Say I have a datepicker component I've written. Typically, an HTML datepicker element would maintain it's own state, but this being React I want to maintain that state myself. So in my […]

Pure React Carousel displaying all slides at the same time

Hello, I would like to have an automatic carousel displaying components. While testing the package out, all slides are displayed simultaneously. My code: <CarouselProvider naturalSlideWidth={100} naturalSlideHeight={125} totalSlides={4} interval={3000} > <Slider> <Slide index={0}> Slide 0 </Slide> <Slide index={1}> Slide 1 </Slide> <Slide index={2}> Slide 2 </Slide> <Slide index={3}> Slide 3 </Slide> </Slider> </CarouselProvider> Sorry for the […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.