I have implemented pyodide in a React App like so.
In src/App.js
in the example from the link above, let's say I have someProperty
in App()
that I want to access from script.py
.
const App = () => {
const [output, setOutput] = useState("(loading...)");
const [someProperty, setSomeProperty] = useState("Initial state"); // this one
const runScript = code => {
window.pyodide.loadPackage([]).then(() => {
...
Under normal circumstances of pyodide, I would use import js
to access javascript scope from python like in the docs.
The JavaScript scope can be accessed from Python using the js module (see Using Javascript objects from Python). This module represents the global object window that allows us to directly manipulate the DOM and access global variables and functions from Python.
However, the property is inside App()
, not directly under window
.
How would I access someProperty
inside App()
from script.py
?
In other words, where is App()
located under window
property? Is it even possible to access properties of App()
globally?