Coder Social home page Coder Social logo

Comments (5)

eneskarpuz avatar eneskarpuz commented on July 18, 2024

Thanks @reggie3. I agree, it would be useful. I'm waiting for your PR to merge but you'd better check these before you submit a PR;
1- I'm not sure about using type annotations like (text: string) .

onChangeText={(text) => console.log(text)}

isn't it better ?
2- You can add your Callback Function to onText function on DragTextEditor.js like;

onText=(text)=>{
... 
const {
 onChangeText,
} = this.props;

if ( text && onChangeText ){
 onChangeText(text);
 }
}

from react-native-drag-text-editor.

reggie3 avatar reggie3 commented on July 18, 2024

Sorry about the string annotation, I copied and pasted the code sample from a typescript file.
It makes sense to use the functionality you already have to implement the callback. I'll submit a PR based on what you said above.

from react-native-drag-text-editor.

reggie3 avatar reggie3 commented on July 18, 2024

@eneskarpuz How about this:

  onText = (text) => {
    this.setState({ text }, () => {
      if (text && this.props.onChangeText) {
        this.props.onChangeText(this.state.text);
      }
    });
  };

This way, the data sent back from the callback is in sync with what is in the component state.

from react-native-drag-text-editor.

eneskarpuz avatar eneskarpuz commented on July 18, 2024

Thanks @reggie3! Looks like a good idea. I think it'd be better to talk this on a PR.

from react-native-drag-text-editor.

reggie3 avatar reggie3 commented on July 18, 2024

Closing since this feature has been merged.

from react-native-drag-text-editor.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.