Answer the question
In order to leave comments, you need to log in
How can you display the value of a variable other than console.log?
I'm new to programming, and maybe asking a stupid question, but still.
Dealing with a page written in React, trying to display the value of a variable through console.log
Approximate page structure
export default class extends Component {
функции(){}
функции(){}
render() {
}
}
Answer the question
In order to leave comments, you need to log in
The Class construct does not allow inserting simple code into the body, only functions, can you insert console.log() instead of a class method?
class ClassName extends PureComponent{
constructor(props) {
super(props)
this.testMethod = this.testMethod.bind(this);
console.log('constructor')
}
componentDidMount() {
console.log(123 + 'componentDidMount')
this.testMethod();
}
testMethod() {
console.log('testMethod')
}
render(
console.log('render до return')
return <div id='component'>
{console.log('render')}
</div>
)
// console.log(123); // вызовет ошибку
}
Alternatively, you can use localStorage.setItem, .getItem
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question