1

There is a code sample in react's blog. Which looks like this:

export class Counter extends React.Component {
  constructor(props) {
    super(props);
    this.state = {count: props.initialCount};
  }
  tick() {
    this.setState({count: this.state.count + 1});
  }
  render() {
    return (
      <div onClick={this.tick.bind(this)}>
        Clicks: {this.state.count}
      </div>
    );
  }
}

What does the export statement mean in this case? I found this article on mdn but it describes another meaning

1 Answer 1

3

It is used for ES6 modules

In that case it is exporting a class from that module, so you would be able to import it in another module using:

import { Counter } from 'path_to_counter';

You will need something like Webpack to do the module loading if you are using a browser, and possibly a transpiler like Babel.js for the ES6 transpilation

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.