How to override onScriptLoaded function?
See original GitHub issueHi. I’m trying to set a function different from noop (the default) to be triggered but I can’t seem to be able to do it. I’ve tried changing defaultProps
for the wrapped component but that didn’t work.
Ideally, I wanted to be able to define the function when I call the scriptLoader
function, maybe like this:
(the name of my wrapper component is Metrics
)
export default scriptLoader(
[
'http://path.to.my.script.net/script.js'
],'', function(){ console.log('onScriptLoader was called...'); })(Metrics);
Is this (or something like this) possible?
Thank you
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Call javascript function after script is loaded - Stack Overflow
I want to call a js function e.g. loadedContent(); once the above script adds dynamic html. Can someone help me how I can...
Read more >How to override a JavaScript function ? - GeeksforGeeks
In this article, we are given an HTML document and the task is to override the function, either a predefined function or a...
Read more >Callbacks — NUKE Python Developer's Guide v11.3v2 ...
The onScriptLoad knob is visible in the Project Settings > Python tab. ... However, you can change this behavior by using the function...
Read more >jQuery getScript Alternatives | Kevin Chisholm - Blog
The onScriptLoad function takes care of using the console to let us know that the script has loaded and to show us the...
Read more >override a Javascript function inside another function?
override a Javascript function inside another function? - Javascript Function. Javascript examples for Function:Function Nest.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@leozdgao I agree with @oyeanuj . The usage of onScriptLoaded is unclear, it is not described in the docs as well. I want to mount a component after my script loads. How should I use onScriptLoaded in such a case?
Please could someone give an example of how to use the onScriptLoaded function. else going to have to find a different library to use, which sucks 😦
I know the author wrote:
This is how onScriptLoader works: const MockedComponent = AsyncScriptLoader.apply(null, deps)(TestComponent)
<MockedComponent onScriptLoaded={onScriptLoaded} />but, maybe I am benig dense, I don’t under stand how that would relate to the code example in the docco:
import React, { Component } from ‘react’ import scriptLoader from ‘react-async-script-loader’ class Editor extends Component { … componentWillReceiveProps ({ isScriptLoaded, isScriptLoadSucceed }) { if (isScriptLoaded && !this.props.isScriptLoaded) { // load finished if (isScriptLoadSucceed) { this.initEditor() } else this.props.onError() } } componentDidMount () { const { isScriptLoaded, isScriptLoadSucceed } = this.props if (isScriptLoaded && isScriptLoadSucceed) { this.initEditor() } } … } export default scriptLoader( [ ‘https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js’, ‘https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.5/marked.min.js’ ], ‘/assets/bootstrap-markdown.js’ )(Editor)
??