Answer the question
In order to leave comments, you need to log in
How to rewrite react mixins in React es6?
Good afternoon, I'm trying to migrate a project from React es5 to React es6, and I ran into a problem, namely mixins.
I have a component like this
var BasicProfileComponent = React.createClass({
mixins: [GoogleMapApi],
componentWillMount: function() {
this.initializeGoogleMapApi(this.onGoogleApiLoaded);
}
)}
var GoogleMapApi = {
initializeGoogleMapApi: function(callback) {
if (window.apiLoaded) {
callback();
}
// adding calback to a queue
this.pullOfCallbacks.push(callback);
}
}
Answer the question
In order to leave comments, you need to log in
Too little data. Here, an option may be suitable both with transferring logic to component methods, and using HOC or Hooks API.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question