Comments (5)
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.
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.
@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.
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.
Closing since this feature has been merged.
from react-native-drag-text-editor.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-drag-text-editor.