Я пытаюсь использовать PyScript в NextJS, но вижу несколько ошибок. Я понятия не имею, как создать компонент React для PyScript. Кто-нибудь успешно использовал PyScript в ReactJS? Спасибо,
const Home: NextPage = () => {
return (
import datetime as dt
pyscript.write(‘today’, dt.date.today().strftime(‘%A %B %d, %Y’))
def compute_pi(n):
pi = 2
for i in range(1,n):
pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
return pi
pi = compute_pi(100000)
pyscript.write(‘pi’, f’π is approximately {pi:.3f}’)
)
}
Ошибка 1.
Type error: Property 'py-repl' does not exist on type 'JSX.IntrinsicElements'.
Ошибка 2.
Unhandled Runtime Error
Error: Hydration failed because the initial UI does not match what was rendered on the server.
See more info here: https://nextjs.org/docs/messages/react-hydration-error
Ошибка 3.
Приведенный выше
вызывает
JsException(PythonError: Traceback (most recent call last): File "/lib/python3.10/site-packages/_pyodide/_base.py", line 429, in eval_code .run(globals, locals) File "/lib/python3.10/site-packages/_pyodide/_base.py", line 300, in run coroutine = eval(self.code, globals, locals) File "", line 2, in File "", line 129, in write AttributeError: 'NoneType' object has no attribute 'innerHTML' )