2

how can I check this markerPosition value is null or not, I need to assign it a variable laying if its null.

  onSendPress() {
    const { message, markerPosition } = this.props;
    this.props.dispatch({
      type: 'Message/messageSend',
      payload: { message, markerPosition }
    });
  }
3
  • Just wanted to confirm that you are binding props correctly? i.e. your constructor does call super(props)? See this issue Commented May 10, 2017 at 19:42
  • yes just it calls null and crash its very simple just an if statement is enough Commented May 10, 2017 at 20:20
  • so to clarify you figured it out and the answer is a simple if statement correct? If so, feel free to close this out. Commented May 10, 2017 at 20:46

1 Answer 1

1

If you are talking about ensuring that the markerPosition is not null and falling back to a default value, try this then:

onSendPress() {
    const { message, markerPosition= "default value" } = this.props;
    // now if this.props.markerPosition is not defined
    // markerPosition holds the value "default value"

    this.props.dispatch({
      type: 'Message/messageSend',
      payload: { message, markerPosition }
    });
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.