Transfer my code from my local environment to Codepen

This is my first time trying to code with VS code. It works fine in my local environment,
but I have problem to transfer it to Codepen.
The link:

When writing within VS code, I included
import React, { useState, useEffect } from "react"; import "./App.css";
// code here
export default App;

However, I am not sure how should I modify it if I want to transfer it to Codepen.
Can anyone help me? Thank you so much.

Take a look on the link.

1 Like

Hum… still can’t figure it out. I have done pretty much the same as the link.

I would suggest using Codesandbox or Stackblitz for React. If you want to do import/export on Codepen it has to be a Project and it has some ridiculous limitations for free accounts.

Anyway, you can use the React object.

1 Like

add this to the top of your file

const { useState, useEffect} = React

1 Like

Thank you! It works now!

1 Like

Thank you! I will have a look at the two websites you mentioned.

Right, as shown, you can also use destructuring to get the methods out of the object. It looks a bit more like an import and works as you’d expect.

const {useState, useEffect} = React;

1 Like