is there anyway to use
find(), findOneBy(), findBy()
in React JS?
I want to use it for array.
Thank you.
You Could definitely use it like this.
class App extends Component {
render() {
var array1 = [5, 12, 8, 130, 44];
var found = array1.find(function (element) {
return element > 10;
});
return (<div>{found}</div>);
}
}
I suspect that you are asking about to use find(), findOneBy(), findBy() as in getting records from some database?
In that case, you might have a bit of misunderstanding. The purpose of React is to handle your DOM, not doing operations to database (like Eloquent ORM on Laravel, for instance)
What you could do is have your web server handle those operations, while providing a REST API endpoints for your React app to hit.
Other than find(), none of those functions are part of javascript Array.prototype. You can do something like this:
[1,2,3,4,5].find(v => v === 3)
But you can not do the same with findOne and findOneBy.
find(), then you suggest to use a partial reimplementation of .NET's object-relational mapping library. How does it help you to usefind()? If the result is not what is expected, you should instead post: (1) your code, (2) expected result, (3) observed result