[ad_1]
Hi I am trying access a const which is assigned a value within the block scope of componentDidMount() and assign it within a different method but I am having difficulty achieving so. I have tried saving it to state, however 'something' is not defined within renderTable()
My code is as follows:
// Pseudo code:
class tableView extends Component {
componentDidMount()
.......
const something = 'blah';
this.setState(something);
renderTable()
const tableData = [
name: 'Item 1',
data: this.state.something,
,
];
return
......
;
Are there any other approaches to allow me access the something const within renderTable()?
[ad_2]
لینک منبع