Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
State is undefined in React

I have a simple class component in react and what I am trying to do is to save a string variable inside the component's state and pass it as a value via a prop. I am passing it but I get the error that state is not defined, why? What am I doing wrong, how can I pass the state variable correctly? Here is my code:

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Upload } from '@progress/kendo-react-upload';

class CustomListItemUI extends React.Component {
  render() {
    const { files } = this.props;
    return (
      <ul>
        {files.map((file) => (
          <li key={file.name}>
            {file.name}
            <button onClick={(e) => this.props.onRemove(file.uid)}>
              remove
            </button>
          </li>
        ))}
      </ul>
    );
  }
}

class App extends React.Component {
  constructor(props) {
    super(props);
    state = {
      remoteUrl:
        'localhost:3001/applicationImages/318c7960-f28b-4daf-bd8f-97449091d344',
    };
  }

  render() {
    return (
      <div>
        sometext
        <Upload
          batch={true}
          multiple={true}
          defaultFiles={[]}
          withCredentials={false}
          listItemUI={CustomListItemUI}
          saveUrl={'https://demos.telerik.com/kendo-ui/service-v4/upload/save'}
          removeUrl={this.state.remoteUrl}
        />
      </div>
    );
  }
}

ReactDOM.render(<App />, document.querySelector('my-app'));

And here is an example:

https://stackblitz.com/edit/react-qvxy4m-rwom28?file=app/main.jsx

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In App constructor you need this.state={ ... } instead of state={ ... }

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!