Hey guys, I made this website with Hugo and Netlify CMS I think around October 2019 and I created a custom preview for a specific type of post where I need to be able to see if the text content I add fits exactly right. It worked like a charm until last time I checked around February but today I logged in to do some maintenance and I am seeing this error in the preview window: TypeError: this.props.getAsset(…).then is not a function
The website is www.gea-tec.com and the repo is at GitHub - gea-tec/geateconline: Websitde geatec suelos y hormigones
Here is the code I have for the preview, the error is in line 28:
var LabPreview = createClass({
subscribed: true,
getInitialState: function() {
return {
src: '',
};
},
_fetchAsset: function() {
const path = this.props.entry.getIn(['data', 'image']);
path &&
this.props.getAsset(path).then(value => { //Line where problem is!
if (this.subscribed) {
this.setState({ src: value.toString() });
}
});
},
componentDidMount: function() {
this._fetchAsset();
},
componentWillUnmount: function() {
this.subscribed = false;
},
componentDidUpdate: function(prevProps) {
const prevPath = prevProps.entry.getIn(['data', 'image']);
const path = this.props.entry.getIn(['data', 'image']);
if (prevPath !== path || prevProps.getAsset !== this.props.getAsset) {
this._fetchAsset();
}
},
render: function() {
var entry = this.props.entry;
var image = entry.getIn(['data', 'image']);
var bg = this.props.getAsset(image);
console.log(this.state.src);
return h('div', {"className": "lab-service-father"},
h('div', {"className": "lab-service"},
h('div', {"className": "lab-service-img"},
h('img', {src: this.state.src},
)),
h('div', {"className": "lab-service-text"},
h('h3', {"className": "lab-service-text-h3"},entry.getIn(['data', 'title'])),
h('p', {"className": "lab-service-text-p"},this.props.widgetFor('body'))
)
));
}
});
CMS.registerPreviewStyle("/css/component.css");
CMS.registerPreviewTemplate("hormigones", LabPreview);
CMS.registerPreviewTemplate("suelos", LabPreview);
CMS.registerPreviewTemplate("asfalto", LabPreview);
Thanks, any help is much appreciated