ReactJs How to pass component as props with props in react? reactjs pass props,reactjs pass function as prop,reactjs pass

I'm using react-grid library from dev-express, There's a Table component in the library, to which we can pass Cell component, Inside the CustomCell, i am using Menu from Material UI

  <Table
        columnExtensions={tableColumnExtensions}
        cellComponent= {CustomCell}
  />

In the above case menu works fine,

But I want pass props to this component and i tried the following

 <Table
        columnExtensions={tableColumnExtensions}
        cellComponent= {(props)=><CustomCell {...props} someFunc={this.someFunc} />}
/>

In this case Menu doesn't work, I wanted to know if there's an alternative way to achieve the second case.

Answer:1

Given that you surrounding Component provides the props you can go like this:

class Foo extends React.Component {

  someFunc = () => {}

  render () {
    return <Table
      columnExtensions={tableColumnExtensions}
      cellComponent= {() => <CustomCell {...this.props} someFunc= 
        {this.someFunc} />}
      />
  } 
}
Answer:2



  1. reactjs pass props
  2. reactjs pass function as prop
  3. reactjs pass state to child
  4. reactjs pass component as prop
  5. reactjs pass data from child to parent
  6. reactjs pass data from one component to another
  7. reactjs pass state to parent
  8. reactjs pass function as prop to child component

How to set the defaultEditorState with a mark down value. I am using react-draft-wysiwyg. example. const value = "Test Message :)↵↵Click This Link - link↵↵Link Url - link"; I have manage to set the ...

How to set the defaultEditorState with a mark down value. I am using react-draft-wysiwyg. example. const value = "Test Message :)↵↵Click This Link - link↵↵Link Url - link"; I have manage to set the ...

import React, { Component } from 'react'; import { View, Text } from 'react-native'; import Firebase from 'firebase'; class App extends Component { render() { return ( <...

import React, { Component } from 'react'; import { View, Text } from 'react-native'; import Firebase from 'firebase'; class App extends Component { render() { return ( <...