Category "reactjs"

Make a button inside an element clickable while the element itself is also clickable

I have a simple sidebar, that has a bunch of list items in it, and a button right next to the list item, like so: I attached a click handler to the <li>

Approach to creating variants with styled components

What is the best way to create variants using styled components? Heres what i am currently doing. const ButtonStyle = styled.button` padding:8px 20px; bor

React 18 TypeScript children FC

I upgraded to React 18 and things compiled fine. Today it seems every single component that uses children is throwing an error. Property 'children' does not exi

React, different env files with create-react-app

I am trying to set up different environment files in a React project (using create-react-app). I following the official documentation but I am getting an error:

Difference between {Link} and {useNavigate} from 'react-router-dom'

Can anyone please explain the differences between {Link} and {useNavigate} from 'react-router-dom'? I am new to React and I see both {Link} and {useNavigate} ar

TypeError: Failed to load plugin 'jest' declared in '.eslintrc': Class extends value undefined is not a constructor or null

I was updating react-scripts to latest version i.e. 5.0.0 and started seeing above error. One article suggested to upgrade @typescript-eslint to version ^5.0.0

Cannot position react-perfect-scrollbar with scrollTop using React hooks

I have an array of objects being rendered in a table with a react-perfect-scrollbar instance. The code is the following: const myComponent = ({ myArray }) =>

Web3 error when trying to call contract methods

I encounter the following error while trying to run a dapp made using React, Truffle & Ganache. I'm also using web3 version 1.7.1. The problem is that the c

TypeError: Cannot read properties of undefined (reading 'map') while setting up MetaMask to display NFT

I keep getting this error when I run my code Uncaught TypeError: Cannot read properties of undefined (reading 'map') I am tring to set up a Metamask which displ

Rerender a row from Datagrid without refresh the whole list

In a List with DataGrid, in each row I have a button for change status, on button click I show a modal with a form, after submit, in the response I have updated

Cannot read properties of undefined (reading 'map') at NFTContainer for nft collection

So im making a function in react that enables me to connect my react page with my metamask and display my nfts that ive purchaed on opensea onto my webpage once

How to render react components by using map and join?

I have one component which is going to display Array of String. The code looks like this: React.createClass({ render() { <div> this.props.d

Yup / Formik validation using dynamic keys

I am trying to validate a form with a dynamic amount of fields - i.e., data is returned from an API that determines how many rows are shown, and for each row th

'clarinet integrate' quickly fails and nothing is logged to console?

Following https://docs.hiro.so/smart-contracts/devnet I can't get the command clarinet integrate to work. I have installed Docker on my mac and am running versi

React 18 useId cannot be in key

The error: React Hook "useId" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function. So,

React render array of components

Quick question. Anyone know how to render an array of components? Trying to make it easier for a developer to alter a particular component. (It's like a dashboa

Ascii/HTML character code doesn't work within React variable

I have the ascii/html code of a checkmark: ✔ &#10004; In react if I go: <div>&#10004;</div> then it works. but if I go var str

Using multiple context in a class component

How can I use multiple Contexes in a React Class Component? Like how you can use multiple contexes in functional components like calling useContext twice or mor

Passing data child to parent functional components in reactjs

How do you pass data from child functional component to a parent functional component in react. I want the vehicle.drive data which is being passed from the par

Invalid Token Error: Invalid token specified: Cannot read property 'replace' of undefined?

I was trying to decode token created through jwt, so that I can access values in my react page and and use it.But for some reason it shows "InvalidTokenError: I