Why Jest coverage creates an .html file from every component? - react-native

I'm testing a React Native app.
I run jest --coverage and I get 233 files:
I still get the coverage file and I can see the coverage through index.html.
But why the other files.
Here is the package.json
{
"name": "entoutonika",
"version": "0.0.1",
"private": true,
"scripts": {
"8": "react-native run-ios --simulator=\"iPhone 8 Plus\" ",
"11": "react-native run-ios --simulator=\"iPhone 11 Pro Max\" ",
"ios": "react-native run-ios",
"and": "react-native run-android",
"se": "react-native run-ios --simulator=\"iPhone SE (2nd generation)\" ",
"ipad13": "react-native run-ios --simulator=\"iPad Pro (12.9-inch) (5th generation)\" ",
"air": "react-native run-ios --simulator=\"iPad Air (4th generation)\" ",
"start": "react-native start",
"test": "jest --runInBand --detectOpenHandles --forceExit",
"watch": "jest --watch",
"cov": "jest --coverage",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"typecheck": "npx tsc",
"checkformat": "prettier --check \"**/*.{js,jsx,ts,tsx,json}\"",
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,json}\"",
"prepare": "npm run typecheck && lint-staged && husky install",
"postinstall": "npx typesync"
},
"dependencies": {
"#react-native-community/async-storage": "^1.12.1",
"#react-native-community/netinfo": "^7.1.9",
"#react-navigation/drawer": "^6.1.8",
"#react-navigation/elements": "^1.2.1",
"#react-navigation/native": "^6.0.6",
"#react-navigation/native-stack": "^6.2.5",
"firebase": "^9.4.1",
"formik": "^2.2.9",
"lottie-react-native": "^4.1.3",
"moment": "^2.29.1",
"react": "17.0.2",
"react-native": "0.66.1",
"react-native-bootsplash": "^4.0.2",
"react-native-code-push": "^7.0.4",
"react-native-gesture-handler": "^1.10.3",
"react-native-image-picker": "^4.3.0",
"react-native-reanimated": "^2.2.3",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.10.1",
"react-native-sound": "^0.11.1",
"react-native-vector-icons": "^9.0.0",
"react-redux": "^7.2.5",
"redux": "^4.1.1",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"typescript": "^4.4.4",
"yup": "^0.32.11"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/preset-typescript": "^7.16.7",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"#testing-library/jest-native": "^4.0.4",
"#testing-library/react": "^12.1.2",
"#testing-library/react-native": "^9.0.0",
"#types/babel__core": "^7.1.16",
"#types/eslint": "^7.28.2",
"#types/jest": "^26.0.24",
"#types/mocha": "^9.0.0",
"#types/react": "17.0.2",
"#types/react-native": "^0.65.0",
"#types/react-native-vector-icons": "^6.4.9",
"#types/react-redux": "^7.1.20",
"#types/react-test-renderer": "^17.0.1",
"#typescript-eslint/eslint-plugin": "^5.1.0",
"#typescript-eslint/parser": "^5.1.0",
"babel-jest": "^26.6.3",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-testing-library": "^5.0.5",
"husky": "^7.0.0",
"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"lint-staged": ">=10",
"metro-react-native-babel-preset": "^0.66.2",
"react-test-renderer": "^17.0.2",
"redux-devtools-extension": "^2.13.9"
},
"resolutions": {
"#types/react": "^17"
},
"jest": {
"verbose": true,
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"setupFilesAfterEnv": [
"#testing-library/jest-native/extend-expect"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/assetsTransformer.js",
"\\.(css|less)$": "<rootDir>/assetsTransformer.js"
},
"moduleDirectories": [
"node_modules",
"src"
],
"transform": {
"^.+\\.js$": "babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!native-base)/"
],
"setupFiles": [
"./setupJest.js"
]
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": "eslint --cache --fix",
"*.{js,jsx,ts,tsx, json}": "prettier --write"
},
"rnpm": {
"assets": [
"./assets/fonts/"
]
}
}
What I do now is check the coverage, and then delete all the files.
I don't have this issue with React projects.
Is there something wrong with the configuration?

Those files are expected since are part of the repo itself so you can see lines of code covered by your tests etc.
You need to add the folder where those are generated into your .gitignore since the whole coverage shouldn't be tracked in your repo.

Related

How does doing an "npm install" install git hooks?

I am newly(ish) responsible for a git repository. When I clone it and look in the .git/hooks directory, there are only sample hooks.
We use NPM as our package manager for the front end UI. After I run an "npm install", I 'all of a sudden' have real git hooks in .git/hooks. How does this work? What am I looking for?
I figure it is some kind of hook, but I am not sure where to start looking to track it down. In my package.json file I see tslint-react-hooks (TSLint rule that enforces the Rules of Hooks) and react-hook-form (Performant, flexible and extensible forms with easy-to-use validation.), but I think these are red herrings.
I've seen this question Putting Git hooks into a repository which talks about getting hooks in place, but I don't see how it happens for this project.
Here is a copy of my package.json file. Thanks for any insights.
{
"name": "ram",
"version": "1.0.0",
"description": "RAM UI Build Tools",
"scripts": {
"test": "jest --coverage --watchAll",
"testOnce": "jest",
"build": "cross-env NODE_ENV=production node ./Config/prod.js",
"build:dev": "cross-env NODE_ENV=development node ./Config/dev-noserver.js",
"dev": "cross-env NODE_ENV=development nodemon -e js,ts,tsx,json,scss ./Config/dev-noserver.js",
"start": "cross-env NODE_ENV=development node ./Config/dev.js",
"start:full": "webpack-dev-server --progress --config ./Config/dev-noserver-hot.js",
"precommit": "lint-staged"
},
"lint-staged": {
"*.{js,ts,tsx,json,scss}": [
"prettier --write",
"git add"
],
"*.scss": [
"stylelint --fix",
"git add"
],
"*.{ts,tsx}": [
"tslint --fix",
"git add"
]
},
"prettier": {
"singleQuote": true,
"tabWidth": 4,
"printWidth": 120
},
"jest": {
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testMatch": [
"**/?(*.)(spec|test).ts?(x)"
],
"modulePaths": [
"<rootDir>/Content"
],
"testPathIgnorePatterns": [
"/node_modules",
"./Config"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.*",
"!**/*.json",
"!**/index.ts"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"./Config",
"./coverage",
"./Types",
"__snapshots__",
"__tests__",
"index.tsx",
"./Content/Pages",
"./Content/Utils/constants.ts"
],
"coverageReporters": [
"html"
],
"setupFilesAfterEnv": [
"./Config/Test/testFramework.js"
],
"testURL": "http://localhost/"
},
"author": "xxxxxxxxxxxxx",
"license": "UNLICENSED",
"private": true,
"devDependencies": {
"#types/classnames": "2.2.3",
"#types/enzyme": "3.1.10",
"#types/history": "4.6.2",
"#types/jest": "22.2.3",
"#types/jquery": "3.3.1",
"#types/lodash": "4.14.110",
"#types/object-hash": "1.2.0",
"#types/query-string": "6.2.0",
"#types/react-beautiful-dnd": "12.1.2",
"#types/react-bootstrap": "0.32.21",
"#types/react-datepicker": "2.9.5",
"#types/react-dom": "18.0.0",
"#types/react-js-pagination": "3.0.3",
"#types/react-router": "4.0.23",
"#types/react-router-dom": "4.2.6",
"#types/react-test-renderer": "16.0.1",
"#types/react-toggle": "4.0.2",
"#types/styled-components": "5.1.25",
"#types/uuid": "3.4.3",
"#types/webpack-env": "1.13.6",
"#typescript-eslint/eslint-plugin": "5.35.1",
"#typescript-eslint/parser": "5.35.1",
"axios-mock-adapter": "1.15.0",
"cross-env": "5.1.4",
"css-hot-loader": "1.3.9",
"css-loader": "0.28.11",
"ejs-loader": "0.3.1",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.1.1",
"eslint": "8.22.0",
"eslint-config-standard-with-typescript": "22.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-n": "15.2.5",
"eslint-plugin-promise": "6.0.1",
"eslint-plugin-react": "7.31.0",
"html-webpack-plugin": "3.2.0",
"husky": "0.14.3",
"jest": "26.4.2",
"lint-staged": "13.0.3",
"mini-css-extract-plugin": "0.4.0",
"node-sass": "4.14.0",
"nodemon": "1.17.3",
"postcss-flexbugs-fixes": "3.3.0",
"postcss-loader": "2.1.4",
"prettier": "1.19.1",
"react-test-renderer": "18.2.0",
"sass-loader": "7.0.1",
"style-loader": "0.20.3",
"stylelint": "9.2.0",
"stylelint-config-recommended-scss": "3.2.0",
"stylelint-declaration-strict-value": "1.0.4",
"stylelint-declaration-use-variable": "1.6.1",
"stylelint-formatter-pretty": "1.0.3",
"stylelint-scss": "3.0.0",
"stylelint-webpack-plugin": "0.10.4",
"ts-jest": "26.3.0",
"ts-loader": "8.0.3",
"ts-react": "1.2.1",
"tsconfig-paths-webpack-plugin": "3.0.4",
"tslint": "6.1.3",
"tslint-config-prettier": "1.18.0",
"tslint-loader": "3.5.4",
"tslint-react": "5.0.0",
"tslint-react-hooks": "2.2.2",
"typescript": "4.6.4",
"webpack": "4.46.0",
"webpack-cli": "2.0.14",
"webpack-dev-server": "3.10.3",
"xml2js": "0.4.19"
},
"dependencies": {
"#hapi/cryptiles": "*",
"#types/react-table": "6.7.12",
"axios": "0.27.2",
"babel-loader": "8.2.5",
"bootstrap": "3.3.5",
"chokidar": "3.5.3",
"classnames": "2.2.5",
"core-js": "3.24.1",
"ejs": "3.1.8",
"eslint-config-airbnb": "19.0.4",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-react-app": "7.0.1",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-utils": "3.0.0",
"eventsource": "2.0.2",
"expose-loader": "0.7.5",
"file-loader": "1.1.11",
"font-awesome": "4.7.0",
"highcharts": "10.1.0",
"highcharts-react-official": "3.0.0",
"history": "4.7.2",
"jquery": "2.1.1",
"json-schema": "0.4.0",
"lodash": "4.17.21",
"object-hash": "1.3.1",
"popper": "1.0.1",
"powerbi-client": "2.18.6",
"powerbi-client-react": "1.3.3",
"prop-types": "15.6.1",
"querystring": "0.2.0",
"react": "18.2.0",
"react-beautiful-dnd": "13.0.0",
"react-bootstrap": "0.33.1",
"react-datepicker": "4.8.0",
"react-dev-utils": "12.0.1",
"react-dom": "18.2.0",
"react-filtered-multiselect": "0.5.1",
"react-hook-form": "6.5.3",
"react-input-switch": "2.2.2",
"react-js-pagination": "3.0.3",
"react-promise": "2.0.3",
"react-query": "3.39.0",
"react-router-dom": "4.2.2",
"react-socks": "2.2.0",
"react-string-replace": "0.4.1",
"react-super-select": "1.0.23",
"react-table": "6.8.6",
"react-table-hoc-fixed-columns": "1.0.0-beta.9",
"react-toastify": "5.5.0",
"react-toggle": "4.1.3",
"shell-quote": "1.7.3",
"string-replace-to-array": "1.0.3",
"styled-components": "5.3.5",
"sweetalert": "2.1.2",
"sync-request": "6.0.0",
"tar": "6.1.11",
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"uglify-js": "3.15.5",
"url-parse": "1.5.10",
"uuid": "8.3.2",
"webpack-dev-middleware": "5.3.3"
}
}
Installing devDependency "husky": "0.14.3" is the culprit.

react native eslint pre-commit does not work

I want to enforce eslint rules before commit and I have configured pre-commit in react-native package.js file but it is not showing eslint error on commit. if I run yar run lint works fine.
Below is my Package.js file
{
"name": "test",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "17.0.2",
"react-native": "0.65.1",
"storyblok-js-client": "^4.0.9",
"react-query": "^3.19.1",
"react-redux": "^7.2.4",
"graphql": "^15.5.0",
"graphql-request": "^3.5.0",
"react-native-typography": "^1.4.1",
"rn-fetch-blob": "^0.12.0",
"react-native-webview": "^11.13.0",
"base-64": "^1.0.0"
},
"devDependencies": {
"#babel/core": "^7.15.5",
"#babel/runtime": "^7.15.4",
"#react-native-community/eslint-config": "^3.0.1",
"#typescript-eslint/eslint-plugin": "^4.31.1",
"#typescript-eslint/parser": "^4.31.1",
"babel-jest": "^27.2.0",
"eslint": "^7.32.0",
"eslint-plugin-react": "^7.25.1",
"jest": "^27.2.0",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2",
"#testing-library/react-native": "^7.2.0",
"eslint-plugin-jest": "^24.4.0",
"fetch-mock": "^9.11.0",
"husky": "^7.0.2",
"lint-staged": "^11.1.2",
"typescript-styled-plugin": "^0.18.1"
},
"lint-staged": {
"src/**/*.{ts,tsx, js, jsx}": [
"eslint --ext .tsx --ext .ts src/ --fix"
],
"./src/**": [
"prettier --write ."
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && pretty-quick --staged"
},
"jest": {
"preset": "react-native"
}
}
}
Did you run husky install?
You can also try to add a file named 'pre-commit' to the .husky folder with the following content:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

Unable to resolve module `assert` from `node_modules\#jest\console\build\BufferedConsole.js`: assert could not be found within the project

I started getting this error all of a sudden on my working react-native app. I have tried all possible solutions available on other questions like clearing cache and all but nothing worked for me.
Even I tried to run my previous working apps and creating new app but getting the same error for all.
Please let me know if you need any further details to look into the issue.
Any kind of help will be much appreciated.
Thanks in advance.
Below is my package.json
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"rnpm": {
"assets": [
"./assets/fonts"
]
},
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint .",
"clean": "react-native-clean-project"
},
"dependencies": {
"#react-native-community/masked-view": "^0.1.10",
"#react-navigation/bottom-tabs": "^5.9.1",
"#react-navigation/drawer": "^5.9.2",
"#react-navigation/material-bottom-tabs": "^5.2.18",
"#react-navigation/native": "^5.7.5",
"#react-navigation/stack": "^5.9.2",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-clean-project": "^3.4.0",
"react-native-gesture-handler": "^1.8.0",
"react-native-reanimated": "^1.13.1",
"react-native-safe-area-context": "^3.1.8",
"react-native-screens": "^2.11.0",
"react-native-splash-screen": "^3.2.0",
"react-native-tab-view": "^2.15.1",
"react-native-vector-icons": "^7.1.0",
"react-native-webview": "^10.9.0"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}

javascript bundle error after upgrading to expo SDK 38 and expo-cli 3.22.3 and, downgrading node js to 12.18.3 [duplicate]

This question already has answers here:
node_modules/expo/AppEntry.js: Transformer.transform is not a function
(3 answers)
Closed 2 years ago.
I have recently upgraded to the latest expo SDK version 38 from 36, and I have been having javascript build error. I have upgraded the SDK with expo upgrade and by running npm install to install the dependencies. Thanks for your help in advance.
Error: Building JavaScript bundle: error: node_modules/expo/AppEntry.js: Transformer.transform is not a function
package.json:
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"lint": "eslint src -c .eslintrc.json --ext js,jsx"
},
"dependencies": {
"#react-navigation/native": "^5.0.0-alpha.22",
"#use-expo/font": "^2.0.0",
"expo": "^38.0.0",
"expo-constants": "~9.1.1",
"expo-contacts": "~8.2.1",
"expo-image-picker": "~8.3.0",
"expo-local-authentication": "~9.1.1",
"expo-notifications": "~0.3.3",
"expo-permissions": "~9.0.1",
"expo-sms": "~8.2.1",
"lodash.debounce": "^4.0.8",
"lodash.memoize": "^4.1.2",
"lodash.orderby": "^4.6.0",
"lottie-react-native": "~2.6.1",
"mem": "^6.0.1",
"moment": "^2.24.0",
"react": "16.11.0",
"react-dom": "16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-animatable": "^1.3.3",
"react-native-elements": "^1.2.7",
"react-native-gesture-handler": "~1.6.0",
"react-native-keyboard-accessory": "^0.1.10",
"react-native-modal": "^11.5.3",
"react-native-reanimated": "^1.9.0",
"react-native-screens": "^2.9.0",
"react-native-smooth-pincode-input": "^1.0.9",
"react-native-svg": "^12.1.0",
"react-native-vector-icons": "^7.0.0",
"react-native-web": "~0.11.7",
"react-navigation": "^4.0.10",
"react-navigation-stack": "1.10.3",
"react-navigation-tabs": "^2.7.0",
"react-redux": "^7.1.3",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"#babel/core": "^7.0.0",
"babel-preset-expo": "^8.2.3",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-node": "^4.0.0",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.1.2",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^1.7.0",
"husky": "^3.1.0",
"metro": "^0.61.0",
"prettier": "^1.19.1"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
}
},
"private": true
}
app.json:
{
"expo": {
"name": "Wif",
"slug": "wif",
"privacy": "public",
"platforms": [
"ios",
"android",
"web"
],
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
}
}
}
I am not 100% sure but I think it has to do with the metro configuration.
Try this package https://www.npmjs.com/package/#expo/metro-config

Babel configuration for react-native Expo

so i am trying to run this react-native app built on expo i am having trouble configuring things.
here's my .babelrc
{
"presets": ["#babel/preset-env","#babel/react"],
"plugins": [
"#babel/plugin-proposal-class-properties"
]
}
my package.json
{
"name": "APP NAME",
"version": "0.1.0",
"private": true,
"devDependencies": {
"#babel/preset-react": "^7.9.4",
"babel-eslint": "^10.0.1",
"babel-preset-env": "^1.7.0",
"eslint": "^5.7.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.25.1",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"jest-expo": "^37.0.0",
"react-native-debugger-open": "^0.3.17",
"react-native-scripts": "1.11.1",
"react-test-renderer": "16.2.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"lint": "eslint --ignore-path .gitignore .",
"lint:fix": "eslint --fix --ignore-path .gitignore .",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js",
"debug": "open 'rndebugger://set-debugger-loc?host=localhost&port=19001'"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"#react-native-community/viewpager": "^3.3.0",
"axios": "^0.18.0",
"babel-preset-react-native": "^4.0.1",
"date-fns": "^1.29.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
"expo": "^37.0.0",
"lodash": "^4.17.10",
"prop-types": "^15.6.2",
"react": "16.9.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",
"react-native-app-intro-slider": "^0.2.4",
"react-native-chart-kit": "^1.2.1",
"react-native-datepicker": "^1.7.2",
"react-native-hr-component": "^1.0.6",
"react-native-mock-render": "^0.1.2",
"react-native-modal-datetime-picker": "^6.0.0",
"react-native-paystack": "^3.1.4",
"react-native-picker-select": "^5.1.0",
"react-native-scrollable-tab-view": "^1.0.0",
"react-native-tab-view": "^2.14.0",
"react-native-vector-icons": "^4.6.0",
"react-native-webview-bridge": "^0.33.0",
"react-navigation": "^2.9.3",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-devtools-extension": "^2.13.5",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.5.3",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.2.0",
"styled-components": "^3.2.3",
"whatwg-fetch": "^2.0.4"
}
}
so at first i had an error like
node_modules/react-native-scrollable-tab-view/node_modules/#react-native-community/viewpager/js/index.js: Plugin/Preset files are not allowed to export objects, only functions. In node_modules/babel-preset-expo/index.js
this got fixed when i remove "babel-preset-expo" from my .babelrc and replaced it with the above content now i am having another error like this:
SyntaxError: /node_modules/react-native-scrollable-tab-view/node_modules/#react-native-community/viewpager/js/index.js: Unexpected token (10:12)
8 | */
9 |
> 10 | import type {PageScrollState as _PageScrollState} from './types';
| ^
11 | import type {PageScrollEvent as _PageScrollEvent} from './types';
12 | import type {PageScrollStateChangedEvent as _PageScrollStateChangedEvent} from './types';
13 | import type {PageSelectedEvent as _PageSelectedEvent} from './types';
Failed building JavaScript bundle
so any ideas why this is happening and how to fix it would be appreciated. Thanks
EDIT:
okay so i have added "react-native" to the babel presets array and the previous error i gone but now i got a new error saying:
node_modules/react-navigation-deprecated-tab-navigator/node_modules/react-native-tab-view/src/TabViewPagerExperimental.js: Cannot read property 'bindings' of null
If there is no .babel.rc present, you can create your own. Add whatever else you may need in there just as you would with .babelrc and it should work. I tried this out yesterday on my Expo managed RN app and it seems to have worked.
// Filename: .babelrc
{
"presets": ["babel-preset-expo"],
"plugins": ["transform-decorators-legacy"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
Edit: This was initial answer...
Expo can be created with two workflows. You would get a .babelrc for a bare workflow, and a babel.config.js for a managed workflow.
If you have "babel.config.js" you could try the following instead of worrying about .babelrc
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: ["babel-plugin-proposal-class-properties"]
};
};