OneCompiler

Inquiry about Pre-filling Default Code in OneCompiler Embed

Dear OneCompiler Support,

I am currently working on integrating the OneCompiler embed feature into a React application. I'm trying to pre-fill the embedded editor with default Python code, but I'm encountering some difficulties.

Here is the code snippet I'm using to embed the OneCompiler editor in my React component:

<iframe className="one-compiler" height="450px" src={`https://onecompiler.com/embed/python?hideTitle=true&defaultCode=${encodeURIComponent(myCusCode)}`} width="100%" ></iframe>

However, despite providing the defaultCode parameter in the URL with the appropriate Python code, the editor does not seem to pre-fill with the specified code upon loading.

Could you please assist me in understanding if there's a specific format or parameter that needs to be set to ensure that the default code is correctly pre-filled in the editor upon loading?

1 Answer

1 year ago by

@gurdhyan singh There is no defaultCode query parameter.
To load a snipped on load, you should embed that specific URL ex.

<iframe className="one-compiler" height="450px" src={`https://onecompiler.com/embed/python/42afvr95k?hideTitle=true`} width="100%" ></iframe>
1 year ago by Karthik Divi