Errors That I've Encountered Flashcards

1
Q

When doing a GET request, what is the gotcha with parameter data?

A

Send as little as possible - when you do need to send it in AXIOS, you can’t send it as a data object the way you do for a PUT - in this case, we tagged it on to the URL as params - according to the AXIOS docs, you could probably build a params object as well, but we didn’t test that out this time.<div><br></br></div><div>Correct:</div><div><br></br></div><div><div><div>axios({</div><div> method: ‘GET’,</div><div> url: ${secrets.api.host}${secrets.api.path}/audits?current_branch=${</div><div> store.getState().branches.currentBranchId</div><div> },</div><div> headers: getHeaders(‘’),</div><div> })</div></div></div><div><br></br></div><div>incorrect:</div><div><br></br></div><div><div>axios({</div><div> method: ‘GET’,</div><div> url: ${secrets.api.host}${secrets.api.path}/audits,</div><div> headers: getHeaders(‘’),</div><div>data: {</div><div> current_branch: store.getState().branches.currentBranchId</div><div>}</div><div> })<br></br></div></div>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What should you do in React Native if a ScrollView won’t scroll to the bottom?

A

It’s likely a flexbox issue interfering and setting an explicit height instead of letting the ScrollView do its thing - so try taking all the flexbox you can out of the ScrollView section.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

If a FlatList won’t scroll to the bottom, what is probably the issue?

A

Make sure ‘flex: 1’ is getting passed down all the way (this includes wrapper views, possibly in other screens)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

If your onClick function is firing on page load - what is likely the problem?

A

“Any time you use () you are firing a function - but if you are passing params you have to include them somehow. So, instead of this:<div><br></br></div><div><img></img><br></br></div><div><br></br></div><div>Bind the function:</div><div><br></br></div><div><img></img><br></br></div><div><br></br></div><div>Or, if you don’t need ‘this’ to be bound, use an arrow function:</div><div><br></br></div><div><img></img><br></br></div><div><br></br></div><div>here is the answer explained:</div><div><br></br></div><div><div>"”Well you don’t<em>have</em>to use .bind().</div><div>All that does is create a new function with the this property set to whatever your first arguments is in the .bind() call.</div><div>The real issue was that your code which didn’t work wasn’t passing a function at all. It was passing the<em>result</em>of a call to your handler function. That’s why it looked like you were getting an event triggered - instead of passing a function, you were calling the handler function while creating the component.</div><div>In the code you posted which did work, it worked because you created a function (using arrow function syntax) which was passed in as the event handler function. When the event is triggered, that arrow function is called and inside of the arrow function the handler function you want is called.</div><div>This is largely the same as using .bind(). Unless your handler function needs ‘this’ as a specific object, there is no need to use .bind().””</div></div>”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

”"”unrecognized font family material icons”” when trying to use an Icon from react-native-elements”

A

This is caused by the fact that, contrary to documentation, react-native-elements needs to be manually linked - after doing so, you must do a pod install in the /ios directory, then it will work.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly