0

I want to create an empty array object in react native that I want to populate with data from a sqlite table. I've searched on google but I only get responses like this.state={} or this.state = { newArr: [] }, but I want to create an empty array of objects similar to const [{ID:'', Name:'', Email:''}].

any idea how I can achieve this?

1 Answer 1

1

Ideally, newArr=[] works. However if you want to make it something like that [{ID:'', Name:'', Email:''}]. It is also possible. Let me share some example.

const initialArr = [{ID:'', Name:'', Email:''}];
class YOURCOMPONENT extends React.Component{
constructor(props){
super(props);
this.state = {
newArr:initialArr,
}
}
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.