react-native-copilot icon indicating copy to clipboard operation
react-native-copilot copied to clipboard

The problem with using copilot and connect in one file.

Open NoKiMa opened this issue 6 years ago • 3 comments

Current Behavior Since copilot requires the use of export default, and I already made export default for connect, a problem arose. All the options that I found to solve the problem allow you to either run or copilot or connect. Here is my code now:

Input Code

import PropTypes from 'prop-types'
class App extends Component {
    static propTypes = {
        start: PropTypes.func.isRequired,
        copilotEvents: PropTypes.shape({
            on: PropTypes.func.isRequired,
        }).isRequired,
    }

    constructor(props) {
        super(props)
        this.waterfallTips = new Tips.Waterfall(
            ['contacts', 'events', 'actionButton'],
            {
                onEnd: async () => {
                    await AsyncStorage.setItem('@Tips', true)
                },
            }
        )

        this.state = {
           // another params of state
            secondStepActive: true,
        }
        this.handleNextTips = this.handleNextTips.bind(this)
        OneSignal.inFocusDisplaying(0)
    }

   
    render() {
        //.....
}


const mapStateToProps = ({
    UserReducer,
    NotificationsReducer,
    GroupsReducer,
    ContactsReducer,
    CalendarReducer,
    ModalsReducer,
}) => {
    return {
        UserReducer,
        contactsData: ContactsReducer.contactsDataToShow,
        NotificationsReducer,
        groupsData: GroupsReducer.groups,
        CalendarReducer,
        ModalsReducer,
    }
}

export default connect(
    mapStateToProps,
    actions
)(copilot()(App))

Expected behavior/code tell me how to make them work together Now I get this error: Снимок экрана 2019-09-09 в 19 19 26

NoKiMa avatar Sep 10 '19 20:09 NoKiMa

Try something like this.

const enhance = compose( copilot({ animated: true, overlay: "svg" }), connect(mapStateToProps, actions) );

export default enhance(App);

import { compose } from "redux";

MuraliMohanRanganath avatar Sep 30 '19 23:09 MuraliMohanRanganath

hai @NoKiMa , try:

export default withNavigationFocus(connect(mapStateToProps, mapDispatchToProps) (copilot({ animated: true, overlay: 'svg', })(HomeScreen)));

syafiq90 avatar Oct 22 '19 10:10 syafiq90

I got it working like this:

export default copilot()(connect(mapStateToProps)(/* you component */))

gilsonviana avatar Jan 24 '20 15:01 gilsonviana