score:2
Accepted answer
you want to pass it as a prop and set the state of the current element. by setting the state, a re-render will be performed (if necessary, which it is in this case) and so the modal will receive the new id.
var projectactivities = react.createclass({
onedititem: function(id){
// i want to pass the id to modal and open it
this.setstate({editingid: id});
},
render: function(){
return (
<div>
<projectactivitylist items={this.state.activities} onedit={this.onedititem}/>
<modal id={this.state.editingid} />
</div>
)
}
});
Source: stackoverflow.com
Related Query
- React: multiple modal and passing props dynamically
- Passing multiple props and actions in react / redux
- React : All the Modal gets opened at once and only last one shows up when I'm passing props inside modal
- Passing multiple value and setter pairs to Context.Provider in React
- Passing multiple props to React component
- React memo components and re-render when passing function as props
- Passing event and props from child to parent in react
- React Native: Passing props between components and componentWillMount() method
- How do i render multiple props in a single component and then pass those props to a child component in React
- React ES6 and passing props
- Passing both match param and props into react component when using routing
- Passing and receiving multiple props to a mapped component
- Passing props to dynamically rendered components in React
- Passing React Props with CSS and using them in a component with TypeScript?
- Map function not working while passing props into React component (TypeScript, React and Next.js)
- React and checking condition after passing function through props
- Syntactic Sugar for passing React props with the same key and value into component
- passing to children all state and props in react
- Error Coming when passing props from one component to another and vice - versa in react using typescript
- React Typescript passing props and data type
- React - Passing props to 'ES6 extends' components, and the correct use of 'bind'
- TypeScript Error in React component on useState declaration and passing props to child component
- React JS - passing info from object and array as props to child component
- react passing multiple functions to components and invoking onClick
- Passing props to React Router which contains multiple components
- Dynamically select React component and apply data as props
- Passing React props and accessing as ObjectName.ObjectName
- React setState dynamically - how to setState property and value from props
- How to render props conditionally and checking for undefined, while passing props via React useHistory?
- Passing Props in React And Substring It In Another Component
More Query from same tag
- ReactJS onChange event handler
- Is it possible to Change Ant designs theme as dynamic
- How to use multiple baseURL axios in ReactJS?
- Lodash _.debounce is not canceling existing timer when function is called again in React
- How to set css of different parts of a Material UI Dialog?
- How to pass a variable to callback of setState in React Component?
- Unhandled rejection: Data is not getting inserted into Mongodb
- document.getElementById for iFrame in ReactJS
- Redirect landing page component 5 seconds
- Axios POST to server returns empty string
- How do I properly set up an API call using useEffect?
- Update existing item or add new item to reducer | React-Redux
- issues with having setState in useEffect causing delayed state change
- React Webcam set Timeout
- Break react-router routes into own file
- Can't get a buttons background image to display
- There are 2 Reacts in one project
- Gatsby category slugs not working from dynamic category page
- Cannot read property 'map' of undefined - Error from ReactJS
- How to use React Router's redirect function?
- A better way to implement axios interceptor
- Webpack - CommonsChunkPlugin (lib building), common.js not loading in parent app
- How can we separate route of admin and user?
- prevent ReactJs component sent from rendering
- React erroring because of different, mystery object
- ReactJs - Conditional Rendering or hiding component
- How to chain promise in redux action
- ReactJS: every subsequent react testing library test after first one fails
- SocketIO emitting message to rooms doesn't work correctly
- How to add class in a common Header component based on the redux data