0

I am trying to pass some info to a child component-class. It is working when im passing it through functions, but how to handle in a class-child

Parent component

export default function Header(props) {
  const propToChild = 'thisisprop'
  return (<FormLayouts propToChild={propToChild}/>)
}

Child component

import React from 'react';
import { withStyles, makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
    root: {
        width: '100%',
    },
}));

class FormLayouts extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            open: false,

        };
    }
  render() {
    console.log(this.props);  //it`s empty((
  }
}

export default withStyles(useStyles)(FormLayouts);
  • 1
    This snippet you sent seems perfectly fine. Can you add more context / info? – Alserda Sep 06 '19 at 06:27
  • 1
    Possible duplicate of [How to pass props to {this.props.children}](https://stackoverflow.com/questions/32370994/how-to-pass-props-to-this-props-children) – norbitrial Sep 06 '19 at 06:29

1 Answers1

0

Its working fine

My mistake, i didnt add prop to state

now

const [currentWindow, setCurrentWindow] = React.useState(<FormLayouts urls={props.urls}/>);

was

const [currentWindow, setCurrentWindow] = React.useState(<FormLayouts />);