Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2017 09:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nagyv/d4e593283da5f1cb7a0fdbca784e47d5 to your computer and use it in GitHub Desktop.
Cannot read property 'state' of undefined
● WhoopsModal component renders correctly as hidden by default
TypeError: Cannot read property 'state' of undefined
import React, { Component } from 'react'
// import PropTypes from 'prop-types';
import { View } from 'react-native'
import {
} from 'native-base'
import Modal from 'react-native-modal'
import ModalStyles from '../Themes/Modals'
import styles from './Styles/WhoopsModalStyle'
export default class WhoopsModal extends Component {
constructor (props) {
this.state = {
isModalVisible: this.props.visible || false,
close () {
this.setState({ isModalVisible: false })
render () {
return (
<Modal isVisible={this.state.isModalVisible}>
<View style={ModalStyles.container}>
<H1 style={{textAlign: 'center'}}>Whoops!</H1>
<Icon name='nuclear' style={{fontSize: 30, textAlign: 'center'}} />
A kért szolgáltatásunk jelenleg nem elérhető. Kérünk, később próbáld újra.
<View style={ModalStyles.buttonContainer}>
<Button onPress={() => this.close()}><Text>Bezár</Text></Button>
import 'react-native'
import React from 'react'
import WhoopsModal from '../../App/Components/WhoopsModal'
import renderer from 'react-test-renderer'
import { shallow } from 'enzyme'
test('WhoopsModal component renders correctly as hidden by default', () => {
const tree = renderer.create(<WhoopsModal />).toJSON()
const wrapper = shallow(<WhoopsModal />)
console.log('wrapper.state', wrapper.state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment