Questions tagged [react-props]

ReactJS is a JS library developed by facebook. Props are the variables to be used in react components. Use tag when having doubts regarding usage of react props.

Reactjs is a JS library developed by facebook. React relies on making of components which handle variables through props.

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

-React Documentation

3283 questions
0
votes
0 answers

Passing the exact props name to a function as a string argument

Can we pass an exact props name to a function as an string without making it a string? For example: function myFunction(prop1){ myFunction1("prop1"); } Is there any way we can pass prop1 as a string without making it as string??
0
votes
2 answers

validate a form in the parent component react

I have a two inputs in my child component, I would like to pass the event of the inputs to my parent component. In the parent component I have a function which will handle the submission. I have the two useState in the parent component, just in case…
unttyy
  • 21
  • 5
0
votes
1 answer

Vercel deployment failed because map() function is mapping props

Thank you in advance for reading and trying to solve my problem. I'm building a next js app and when I tried to deploy my app on Vercel the deployment failed. This is the error that I'm getting : TypeError: Cannot read properties of undefined…
Ermin
  • 43
  • 3
0
votes
0 answers

Component not taking prop passed by the prop

i'm having trouble accessing a property value of a property in my component. The thing is that this is like a component anidation. Layout takes CenterUp in its centerUp prop and at the same time CenterUp takes InnerHeader as its header prop. I want…
0
votes
1 answer

I want to pass data from a child to parent REACT JS

I have a function that selects a country from a dropdown. I have put it in a file by itself. And then on my Dashboard.js I just call the funtion to appear. But how can I get the value from the Dashboard.js? CountrySelector.js import React, {…
0
votes
0 answers

How to create a smart helper function to pass my React props conditionally

I have this existing component in my React app, rendered on a certain Page: {data.program && (
meez
  • 3,783
  • 5
  • 37
  • 91
0
votes
1 answer

Component won't render within another component

When I inject the modal component into the dom it renders fine. However, if I wrap that component and then render the new component into the dom. Nothing renders other than root. Working component: ReactDOM.render((
0
votes
1 answer

should I pass the imported components as props or can I just import it directly in the subcomponent - React JS

I am making a project with different pages, and each pages/main component of the page contains many subcomponents. I have been passing data as props, which is for the single source of truth as I learned it, but I think I misunderstood that concept,…
u_ser
  • 43
  • 4
0
votes
1 answer

How can I build a filter in React with the Autocomplete component from MaterialUI using state?

I am building a filter with the Autocomplete component from MaterialUI. When selecting options from the dropdown: The Autocomplete component also will append to the Chip Array as options are selected. The value of that option is added to an array…
zscrub
  • 45
  • 5
0
votes
0 answers

Child component prop causes "Maximum update depth exceeded"

I have the following two components. Brands.js is a parent component that contains the SearchField component and passes a few props to it. I'll explain each prop: brands is a list of Brand entities each containing an Id and a Name, searchableItems…
leshma
  • 1
  • 2
0
votes
0 answers

Pass a Function from Child to Parent Component | Next.js

So, I have a function in a child component, which produces images, also a button in a parent component which while click needs to fire up a function in the child component Child const ImgCreate = (props: any) => { const [image, setImage] =…
0
votes
4 answers

How to pass a value from child to parent component in reactjs

I had a child component UploadImage.js and parent component Parent.js. I am uploading an image and want to pass the value of file name to the Parent.js component. How can I do so? UploadImage.js import React, { useEffect, useState } from…
MagnusEffect
  • 3,363
  • 1
  • 16
  • 41
0
votes
1 answer

How can I send state to another component in react?

I would like to ask how can I send state from component to another component? I have 3 components and I want to send data between them. So I have an input component where I handle an IP call and I want to send this shortedLink state to another…
Surge
  • 81
  • 8
0
votes
1 answer

Use typescript to define set of non-compatible react props

I have made a component MyComponent with react. I would like to define the props for this component. Usually i do it like type Props = { foo: string } const MyComponent = (props: Props) => ... Here are the props i would like to always be…
johann1301s
  • 343
  • 4
  • 19
0
votes
1 answer

For React Prop Drilling, why is it that I can only pass one State Parameter instead of both the State and the State Setter?

This is just a simple concept question I am trying to understand as I use and learn React, but why can I only send one State Parameter through Prop Drilling? This is if I use either UseState or if I use the XState platform. I don't know if this has…