teleporthq / teleport-code-generators

A collection of code generators for modern JavaScript applications
https://teleporthq.io
MIT License
1k stars 161 forks source link

TypeError: ReactGenerator.generateComponent is not a function #830

Open aadeshkulkarni opened 1 year ago

aadeshkulkarni commented 1 year ago

Trying the sample code shown in readme.MD

index.js

import ReactGenerator from '@teleporthq/teleport-component-generator-react'

const uidl = {
    "name": "My First Component",
    "node": {
      "type": "element",
      "content": {
        "elementType": "text",
        "children": [
          {
            "type": "static",
            "content": "Hello World!"
          }
        ]
      }
    }
  }
const { files } = await ReactGenerator.generateComponent(uidl)
console.log(files[0].content)```

Error:

file:///Users/aadeshkulkarni/Documents/teleportHQ/index.js:18
const { files } = await ReactGenerator.generateComponent(uidl)
TypeError: ReactGenerator.generateComponent is not a function
    at file:///Users/aadeshkulkarni/Documents/teleportHQ/index.js:18:40
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

package.json

{
  "name": "teleporthq",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@teleporthq/teleport-component-generator-react": "^0.33.0-alpha.0"
  }
}
JayaKrishnaNamburu commented 1 year ago

Hello, thanks for reporting this. His is a documentation for the usage of generators. Looks like we need to update the Readme file 😄. Happy to accept a PR :) https://docs.teleporthq.io/guides/getting-started.html