Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined is not a object (evaluating 'promise.done.bind') #182

Closed
kennyzehn opened this issue Aug 9, 2016 · 11 comments
Closed

undefined is not a object (evaluating 'promise.done.bind') #182

kennyzehn opened this issue Aug 9, 2016 · 11 comments

Comments

@kennyzehn
Copy link

kennyzehn commented Aug 9, 2016

Hey guys,

i dont know what goes wrong?! But the first request on the chat component failed with this message -> undefined is not a object (evaluating 'promise.done.bind')

    constructor(props) {
        super(props);
        this.state = {messages: []};
      }

    componentDidMount() {
        this.setState({
            isTyping: true,
            messages: [{
                _id: 1,
                text: 'Hello developer',
                createdAt: new Date(Date.UTC(2016, 7, 30, 17, 20, 0)),
                user: {
                    _id: 2,
                    name: 'React Native',
                    avatar: 'https://facebook.github.io/react/img/logo_og.png',
                },
            },],
        });
    }

    onSend(messages = []) {
        this.setState((previousState) => {
          return {
            messages: GiftedChat.append(previousState.messages, messages),
          };
        });
    }

    render() {
        if(this.state.messages) {
            return (
                <View style={Settings.styles.pageView}>
                    <GiftedChat messages={this.state.messages} onSend={this.onSend.bind(this)} user={{_id: 1}}/>
                </View>
            )
        } else {
            return (
                <Loading />
            )
        }
    }

Any ideas?

@FaridSafi
Copy link
Owner

Hello,
is Settings.styles.pageView defined ?

@kennyzehn
Copy link
Author

Yes it is.

@FaridSafi
Copy link
Owner

What RN version are you using?
Do you have more information in the log?

I created a project using your code and could'nt reproduce, can you prepare a code example?

@kennyzehn
Copy link
Author

kennyzehn commented Aug 9, 2016

"react": "15.2.1",
"react-native": "^0.30.0"

and here the error screen -> https://monosnap.com/file/jnhre3Zbh5PsYZ41cqLYxkxv32rmJ2

Edit:
And if I click on dismiss the chat looks like this -> http://take.ms/mwIEa

@FaridSafi
Copy link
Owner

FaridSafi commented Aug 10, 2016

@kfiroo
Copy link
Collaborator

kfiroo commented Aug 10, 2016

@kennyzehn Are you using an external promise library?

@kennyzehn
Copy link
Author

@kfiroo
Copy link
Collaborator

kfiroo commented Aug 10, 2016

@kennyzehn react-native ships with an implementation of an es6-compatible promise lib (with polyfills for done, finally etc.), so unless you need some special features that your lib offers I would suggest to remove it from your project and use the existing Promise object which is available as a global.

I think it might override the Promise impl with one that does not have done and this is why your app crash.

You would probably be able to reproduce it by using InteractionManager.runAfterInteractions without react-native-gifted-chat

@kennyzehn
Copy link
Author

kennyzehn commented Aug 10, 2016

Thanks @kfiroo! Works much better. But there is also a other bug.
http://take.ms/0qshf

render() {
        if(this.state.messages) {
            return (
                <View style={{flex: 1}}>
                    <GiftedChat messages={this.state.messages} onSend={this.onSend.bind(this)} user={{_id: 1}}/>
                </View>
            )
        } else {
            return (
                <Loading />
            )
        }
    }

Any ideas?

@FaridSafi
Copy link
Owner

is the container of your component bigger than the screen ?

@kfiroo
Copy link
Collaborator

kfiroo commented Aug 10, 2016

@kennyzehn Maybe open a new issue with a relevant title if the bug is real :)
Thanks!

@kfiroo kfiroo closed this as completed Aug 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants