Check out example codes for "java stop script". It will help you in understanding the concepts better.

Code Example 1

public void onClick() {
    if(condition == true) {
        return;
    }
    string.setText("This string should not change if condition = true");
}

Learn ReactJs, React Native from akashmittal.com