Getting "undefined is not an object (evaluating '_react2.proptypes.string')" after importing react-native-prompt - react-native

I am using the newest version of NPM, the version of exp is 57.0.0. When I add to my code in render method, I get an error "undefined is not an object (evaluating '_react2.proptypes.string')". Without adding everything works perfect.
Both Prop-Types and React-native-prompt are installed.
I have already tried to write import Prompt from 'prop-types'; instead of writing import Prompt from 'react-native-prompt'; but then I am getting the error that hasn't been found in Prop-Types.
Any suggestions on how to fix it?
Thank you

PropTypes moved into separate package. Use prop-types package.
react-native-prompt use outdated style of prop-types so you have to manually solve it.
go to /node-modules/react-native-prompt and edit main files in this way:
import { PropTypes } from 'react'
the above line is incorrect and must be like this:
import PropTypes from 'prop-types'
You have to import PropTypes in this way.
More info here.
Note:
React.PropTypes has moved into a different package since React v15.5. Please use the prop-types library instead. We provide a codemod script to automate the conversion.

Related

Why do the recommended import statements for Docusaurus fail?

Importing react components into a Docusaurus markdown file has a common pattern like:
import Figure from '#site/src/components/figure' github source
import BrowserWindow from '#site/src/components/BrowserWindow' official docs
However, this pattern throws an error in my application when I include the following line in docs/theirlabel/latest.md:
import Figure from '#site/src/components/figure'
Throwing the following error
ERROR in ./docs/theirlabel/latest.md 1:991-1039
Module not found: Error: Can't resolve '#site/src/components/figure'
in '/home/projects/github-5c7qs5-wquhko/docs/theirlabel'
Commenting that line allows the site to compile correctly.
I've tried many variations of referencing/including the figure.jsx component without success, like:
import Figure from '/src/components/figure'
import Figure from './src/components/figure'
import Figure from '../src/components/figure'
import Figure from 'src/components/figure'
import Figure from './figure'
import Figure from '/figure'
Any ideas what I'm doing wrong?

Problem with importing SwitchSelector in React Native

I am relatively new to programming and I have some trouble with importing SwitchSelector, which I am going to use to switch language manually in my React Native app, I tried to follow this video: https://www.youtube.com/watch?v=kq9LqHKgNOA&t=47s.
I have installed it with this command: npm i react-native-switch-selector --save
And imported with this line: import SwitchSelector from "react-native-switch-selector";
But under the import line there is dotted line and when I hover over it I get this message: Could not find a declaration file for module 'react-native-switch-selector'. 'C:/Users/carol/Documents/kand_arbete/Sporta/node_modules/react-native-switch-selector/index.js' implicitly has an 'any' type.
Do anyone know how I can fix it? If not, how can I solve this with buttons instead?
I would be really grateful if someone could help me!

React Naitve Error - Invariant Violation: ART has been removed from React Native

ART was imported from 'react-native' in the react-native-progress module.
import { Animated, ART, StyleSheet, View } from 'react-native';
I updated the module and now it imported from #react-native-community/art.
import { Surface as ARTSurface } from '#react-native-community/art';
ART is not used in the project anywhere else, yet I am still facing the same error.
Any idea what's wrong?
Error Message:
Invariant Violation: ART has been removed from React Native. It can now be installed and imported from '#react-native-community/art' instead of 'react-native'. See https://github.com/react-native-community/art.
Screenshot of the error.
By looking at your stack trace, You are using react-native-progress and this is an internal dependency of it and that's why you are facing this issue.
According to docs of react-native-progress.
https://github.com/oblador/react-native-progress/blob/master/README.md#reactart-based-components
So according to docs, you can remove it too for fixing this error.
Note: If you don't want the ReactART-based components and their dependencies, do a deep require instead: import ProgressBar from 'react-native-progress/Bar';.
So either you can avoid using these components which are ART based or try to fix them like below.
in file Circle.js, CircleSnail.js, Pie.js,
replace ART.Surface with
import {Surface} from '#react-native-community/art';
and in file Shapes/Arc.js
import {Shape, Path} from '#react-native-community/art';
and replace the same above.
Any package relies on ART will cause the issue with you , not only react-native-progress , but also packages with loaders like this react-native-loading-spinner-overlay ,
You can change this by finding another package of by fixing your imports
The Art library has been removed as of SDK 36 ,
If you need to use react-native-progress, which relies on ART, you can use the bare workflow and install #react-native-community/art, or implement your own progress indicator using Svg

Navigation with header dropdown works on expo snack but doesn't on CLI

UPDATE with FIX: It was a named import error. Make sure to not use {} imports when you export default components
Navigation stack with a header dropdown works on snack expo but I get a "Invariant violation: ... Check render method of ..." error when I build a simulator on CLI
I've tried adding or removing curly brackets from my imports but it's no use. I suspect it might be something about withNavigation exports in the components or import/exports in the navigation stack
https://snack.expo.io/#kkarakas/kkarakas-snack
Does anyone know what is going on here?
It was a named import error. Make sure to mostly not use {} imports on components

Redux doesn't play well with Platform specific classes, ToolbarModal.ios.js version doesn't connect mapDispatchToProps

I can't access the prop functions inside *.ios.js file, the android counterpart works well.
export default connect(mapStateToProps, {
updateTextInput, onResetPressed, getRecentSearches, getPopularNearYou,
filterWhereSelected,
})(ToolbarModal);
stupid mistake from my part, my action creator had a faulty, circular import:
import Suggestions from "../components/toolbarModal.ios";
corrected the import and everything works.. it would have been nice if Webstorm would have not proposed this import or it would have detected there is no Suggestions in toolbarModal.ios.