Answer the question
In order to leave comments, you need to log in
How to properly import a regular class into a React component?
Hello. There is a Store class that needs to be imported into the App component, but crashes "Expected an assignment or function call and instead saw an expression no-unused-expressions". What am I doing wrong?
Store:
export default class Store {
constructor(reducer) {
this._reducer = reducer;
this._state;
this._callbabks = [];
}
dispatch(action) {
this._state = this._reducer(this._state, action);
this._callbabks.forEach(item => item());
}
get state() {
return this._state;
}
subcribe(callback) {
this._callbabks.push(callback);
return callback;
}
unsubcribe(callback) {
this._callbabks = this._callbabks.filter(item => item !== callback);
}
};
import React, { Component } from 'react';
import './App.css';
import Store from './redux/store'
class App extends Component {
render() {
return <h1>Test</h1>
}
}
export default App;
Answer the question
In order to leave comments, you need to log in
no-unused-expressions
linter error . Importing a module but not using it.
Learn to read and understand the texts of errors, as well as independently google solutions to problems. To do this, just enter the text of the error in the search engine.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question