maticzav / ink-table

📐A table component for Ink.
187 stars 33 forks source link

Element type is invalid #143

Closed tetuaoro closed 3 years ago

tetuaoro commented 3 years ago

Hi, I got an error when I render a simple app Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object..

The error was provided by Table from ink-table.

App.tsx simple_app_counter_throw_error

I can't find any issues for this ! Hope you can help me..

tsconfig { "extends": "@sindresorhus/tsconfig", "compilerOptions": { "jsx": "react", "esModuleInterop": true, "outDir": "dist" }, "include": ["source"] }

package.json { "name": "simple-counter", "version": "0.0.0", "license": "MIT", "main": "dist/index.js", "type": "module", "engines": { "node": "14.17.0" }, "scripts": { "build": "tsc", "prestart": "yarn run build", "start": "yarn run serve", "serve": "node ." }, "files": [ "dist/index.js" ], "dependencies": { "dotenv": "^10.0.0", "ink": "^3.0.8", "ink-table": "^3.0.0", "react": "^16.14.0" }, "devDependencies": { "@sindresorhus/tsconfig": "^1.0.2", "@types/node": "^16.0.0", "@types/react": "^17.0.13", "chalk": "^4.1.1", "eslint-plugin-react": "^7.24.0", "eslint-plugin-react-hooks": "^4.2.0", "ink-testing-library": "^2.1.0", "typescript": "^4.3.5" }, "peerDependencies": { "eslint": "^7.30.0" } }

tetuaoro commented 3 years ago

Ok, if any devs had the same error, here is the solution : don't compile like a module. First, nodejs don't resolve paths of multi components with module and the last, lot of configuration in the default tsconfig (create-ink-app) doesn't work for me. I just remove the extends module.

Hope this help ! :+1:

new tsconfig { "compilerOptions": { "jsx": "react", "esModuleInterop": true, "outDir": "dist" }, "include": ["source"] }

new package.json ... "type": "commonjs", ...

flexwie commented 3 years ago

@tetuaoro Do you have a public repository with your code by any chance? I am running into the same issue but the config you provided is not doing it for me sadly...

tetuaoro commented 3 years ago

@tetuaoro Do you have a public repository with your code by any chance? I am running into the same issue but the config you provided is not doing it for me sadly...

@flexwie sorry it's not a public repo 😇