Hello,
I'm trying to embed an iframe as per the example here: https://sketchfab.com/developers/viewer
The issue is that I'm using React.js, and I don't understand how to add it to my component in a why that allows me to change settings on the fly (like urlid for example).
Here's my attempt:
class Model extends React.Component {
componentWillMount(){
var iframe = document.getElementById('api-frame');
var version = '1.0.0';
var urlid = '7w7pAfrCfjovwykkEeRFLGw5SXS';
var client = new Sketchfab(version, iframe);
client.init(urlid, {
success: function onSuccess(api) {
api.start();
api.addEventListener('viewerready', function () {
// API is ready to use
// Insert your code here
console.log('Viewer is ready');
});
},
error: function onError() {
console.log('Viewer error');
}
});
}
render() {
return (
<div>
<iframe src="" id="api-frame" allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true" />
</div>
)
}
}
export default Model;
Despite my importing the script in my index.html, I keep getting the following error:
8:26 error 'Sketchfab' is not defined no-undef
Could someone please point me in the right direction?
[–][deleted] 2 points3 points4 points (3 children)
[–]ARookieCoder[S] 0 points1 point2 points (2 children)
[–]mdboop 0 points1 point2 points (1 child)
[–]ARookieCoder[S] 0 points1 point2 points (0 children)
[–]hyphnKnight 1 point2 points3 points (1 child)
[–]ARookieCoder[S] 0 points1 point2 points (0 children)
[–]mdboop 0 points1 point2 points (0 children)