How can I pass array values to a property of Object?

I have two arrays(word and translatedWord). They contain words(word array contains words in english and translatedWord contains the same words but in another language ). I want to create an array of objects, each object to have the properties value, translation and id. I solved how I can create an object with the translatedWord properties,… Read More How can I pass array values to a property of Object?

React hook form useFormContext generating "argument of type 'string | undefined'" error

I am new to react and I am using react-hook-form useFormContextand it is generating the following error, Argument of type ‘string | undefined’ is not assignable to parameter of type ‘string’. Type ‘undefined’ is not assignable to type ‘string’. and I am not sure why. My code is the following, const mapFields = new Map([[‘d1’,… Read More React hook form useFormContext generating "argument of type 'string | undefined'" error

Why if-else is not working in this react code, cause I am not getting output?

I was trying to achieve something like this in react e.g. user enter his/her age and when click the button following logic should work if age>18 then Eligible for Passport else Not eligible But I am getting no output when I enter the age and click the Enter button. import { useState } from "react";… Read More Why if-else is not working in this react code, cause I am not getting output?

Couldn't able to see all the options in the drop-down menu after selecting one in React

I have student data. I want to filter and display names and IDs based on date. I can select the date but once I choose a date the dropdown menu shows only that particular date, not the other dates. I want to see all the dates whenever I click the input field. Could you please… Read More Couldn't able to see all the options in the drop-down menu after selecting one in React

How can I get data based on id and pass data text field for editting

Trying to edit the blog data based on blog id, but I am not able to get the blog data. I would like to display the data in the input name columns heading, tags under the Blog data to display for edit. Could someone please advise ? CSB link: https://codesandbox.io/s/practical-turing-x8ph7k?file=/src/App.js import "./styles.css"; import React, {… Read More How can I get data based on id and pass data text field for editting

How to convert a nested object into an array of group options (React hooks)

I am a new dev and I am having trouble converting this nested object into an array of options with categories. Response from API call: { "category1": [ { "categoryCode": "category1", "categoryLabel": "Vehicles", "code": "AAA", "label": "Car a" }, { "categoryCode": "category1", "categoryLabel": "Vehicles", "code": "BBB", "label": "Car b" } ], "category2": [ { "categoryCode":… Read More How to convert a nested object into an array of group options (React hooks)

Property 'setCurrentUser' does not exist on type 'Object'.ts(2339) with useContext

I was trying to pass useState properties through Context.Provider value={{theme, setTheme}} as it was written in tutorial, and after receive it with useContext(Context), but it keeps returning me an error: const setCurrentUser: any Property ‘setCurrentUser’ does not exist on type ‘Object’.ts(2339) Note: This code is fully copied from react docs with little type additions to… Read More Property 'setCurrentUser' does not exist on type 'Object'.ts(2339) with useContext

Why I getting an error while trying to use map on data that i get using hook?

I trying map data which i get using custom hook that recives data from my "storage" (which is actually a class with array of objects and async function to get them) i reciving an error: Cannot read properties of undefined (reading ‘map’). Code of hook: const useCreations = () => { const service = new… Read More Why I getting an error while trying to use map on data that i get using hook?