Category "reactjs"

What are assertions in JEST?

It's documentation says that while dealing with async code, expect.assertions(x) should be written. What exactly do assertions refer to? Is it a term of plain J

React - Jest - Enzyme: How to mock ref properties

I'm writing test for a component with ref. I'd like to mock the ref element and change some properties but have no idea how to. Any suggestions? // MyComp.jsx

Why remove QA IDs from the code base in production

In a React application that we are developing we use QA IDs for Selenium tests. Is it bad practice to leave them in the code base in production (live)? If so,

NextJS: How to correctly add firebase analytics to NextJS app

I have a react/nextjs app and I have firebase.js as follow: import firebase from 'firebase/app' import 'firebase/auth' import 'firebase/analytics' import 'fireb

I can't install react using npx create-react-app?

I am trying to use npx create-react app but i have errors that is shown below: npm ERR! Unexpected end of Json input while parsing near '...eact-app/-/create-r

override formik.onChange with custom onChange method in reactjs

I'm trying to get the value of a file input so that I can make a custom file input. But when I try to pass the value using onChange prop the value is not passin

display avatar on the last current message in case of subsequent messages

I am working on a chat box where I need to show the messages of users by grouping the messages on a particular date. The grouping has been working fine so far.

How to create an admin route and another private route for registered users with a normal route?

I have used this code as the private route, but I want a another separate route only for admins. How can I change the code? import React from 'react'; import {

Using react-highcharts, trying to update the xAxis categories values, but it doesn't, it keeps the values in my config variable.

As stated above, I can't seem to get the categories to re-render when I am using the react-highchart library. I seem to be able to set the data of the chart val

React unable to import component -- module not found

I just started with React.js and I am unable to import component. I have this structure as followed by this tutorial (YouTube link) : -- src ----| index.html

Prevent re-sort on data change or while row is being edited

On react-table when the table is sorted and data changes, the table can either reset (go to default sort state) or re-sort (by putting the edited row in the cor

emotion css feature is not rendering the styles (React)

I´m using Webpack 4, Babel 7 and Emotion 10. I installed @emotion/core @emotion/styled and the recommended plugin babel-plugin-emotion styled is working

"Peer dependency not installed" warning, but they are installed

On npm install, I am getting the following "peer dependency not installed" warnings: npm WARN [email protected] requires a peer of react@^0.14.1 but none is i

Ubuntu create-react-app fails with permission denied

I'm getting a weird error: Unhandled rejection Error: EACCES: permission denied, mkdir '/home/ubuntu/.npm/_cacache/index-v5/14/36'atus I just install npm (6.

react native : custom component with color parameter

Im doing the exercises to learn react native on codecademy. I am told "In React, properties are passed as objects on the first parameter to our components. You

React-testing-library: changes due to input

I'm trying to test that a component updates as it should due to changes in an input element. I use the fireEvent.change()-function, and if I then check the valu

React Link doesn't refresh the page

I have this code: <Link to="/dashboard" style={{ color: '#A4A4A4' }}>Dashboard</Link> As part of my app, but if i'm currently viewing the /dashboa

How to make reactjs website responsive using material-ui

I am working on reactjs project using material-ui. Web-page is working perfect on desktop layout but when I switch layout to responsive (mobile). Than all the t

How to prevent re-rendering of components that have not changed?

I have a component that consists of several other components such as text fields, and when an input is made to the text field, all other components are re-rende

Target Active Link when the route is active in Next.js

How to target the active Link in Next.js like they way we do it in React-Router-4? Meaning, give the active link a class when its route is active?