Question: I'm trying to pass props for width from a parent component to a child JS file, but cannot seem to get the props value in the child JS file. The parent is the following:

```
import React from 'react';
import Child from './Child';
export default class Home extends React.Component {

    state = {
        width: 1000
    }

    render(){

        return(
            <div>
                <Child width={this.width} />
            </div>
        );
    }
}

```

The separate child JS file is the following:

```
import React from 'react';
const svgWidth = 650, // Load prop here
      svgHeight = 340;

```

What I've tried is the following but is not working for me:

```
import React from 'react';
const Child = (props) => {

    console.log({props.width}); // Getting an error that ',' is expected

    return {props.width};
}

```

Can someone please help me with passing the width value from ?

Answer: 
Change to the following, as you should access state through `this.state`, like so:

```
<Child width={this.state.width} />

```
If you intend to pass props to a child component, then I would start with the following:

```
import React from 'react';
import Child from './Child';
export default class Home extends React.Component {
  constructor(props) { // don't forget to add a constructor
    super(props); // also required
    this.state = {
      width: 1000
    }
  }

  render(){
    // to pass state use {this.state}
    return(
      <div>
        <Child width={this.state.width} /> 
      </div>
    );
  }
}

```

However, if that is not the case and instead you want to export state to a separate js file (that may not even be a React component), then you may have to look at export syntax. I am struggling with a similar problem right now and I already tried what Vikash Kumar suggested without success. This is explained on this question but I was not successful with that approach either: [export function inside react component or access state in same file outside of component](https://stackoverflow.com/questions/57417643/export-function-inside-react-component-or-access-state-in-same-file-outside-of-c)