Talor-A / react-native-message-bar

A notification bar alert displayed at the top of the screen for react-native
MIT License
55 stars 27 forks source link

2.1.0 - React-Native 0.64.2 - Could not find a declaration file for module 'react-native-message-bar'. #43

Closed rodrigoalvez closed 3 years ago

rodrigoalvez commented 3 years ago

Hi, I'm migrating from RN 0.59 to 0.64.2 and this is the only component that's not working. I have only one file where I use react-native-message-bar and then I import that file to my Router in order to use it with react-native-router-flux.

My class component is named MessageBarRegister and here it is:

import React, { Component } from 'react'; // @ts-ignore import { MessageBarAlert, MessageBarManager } from 'react-native-message-bar'; import { connect } from 'react-redux'; import { cleanError } from '../../redux/actions';

class MessageBarRegister extends Component { componentDidMount() { // Register the alert located on this master page // This MessageBar will be accessible from the current (same) component, and from its child component // The MessageBar is then declared only once, in your main component. MessageBarManager.registerMessageBar(React.createRef()); }

componentWillReceiveProps(nextProps) { if ((this.props.error !== nextProps.error) && nextProps.error !== '') { if (nextProps.error.status === 418) { MessageBarManager.showAlert({ animationType: 'SlideFromLeft', onHide: this.onHide(), title: 'Alerta', duration: 5000, message: nextProps.error.message, alertType: 'info', // See Properties section for full customization // Or check index.ios.js or index.android.js for a complete example }); } else { MessageBarManager.showAlert({ animationType: 'SlideFromLeft', onHide: this.onHide(), title: 'Error', duration: 5000, message: nextProps.error, alertType: 'error', // See Properties section for full customization // Or check index.ios.js or index.android.js for a complete example }); } } }

componentWillUnmount() { // Remove the alert located on this master page from the manager MessageBarManager.unregisterMessageBar(); }

onHide() { this.props.cleanError(); }

render() { return (); } }

const mapStateToProps = state => ({ ...state, error: state.error.errorData, });

export default connect(mapStateToProps, { cleanError })(MessageBarRegister);

Someone knows how to correct this issue? In RN 0.59 it worked as expected.