How can I reference my array of markers using setState? - react-native

I have some old code that used to run but now I receive a warning. When fixing it using setState, I get a simple syntax error. Obviously I am misunderstanding something but not sure what. I have provided a snack example here that reproduces my error exactly.
calling setState causes error - Do not mutate state directly
I also included my original line below. It used to work fine.
From looking at a similar question I tried using just this.state.markers which gives the same error.
I appreciate any and all insight more than you know.
ref={ref => this.state.markers[index] = ref}

typo in line 29, it should be
markers: [],

Related

React-Redux Error: undefined is not a function

I have use React-Redux. When I get data from store and use useSelector hook. this error occur and say 'undefined is not a function'. I have found on internet but no answer I haven't found. Please help me. I am stuck in this error. Thank you
Since you did not supply any code, I could only give several possible causes for this kind of error.
Check your spellings. Getting undefined is because you are referencing a json key that does not exist.
Check if you have initialized your state in your reducer.
You can debug both 1 and 2 using the following method:
const {param1, param2} = useSelector(state => {
console.log(state)
return state.yourReducer
});

Getting FusionAuthClient is not a constructor error

I am trying the fusionauth-node-client and following the wiki https://fusionauth.io/docs/v1/tech/client-libraries/node. But I am getting the following error
const client = new FusionAuthClient('6b87a398-39f2-4692-927b-13188a81a9a3', 'http://localhost:9011');
^
TypeError: FusionAuthClient is not a constructor
at Object.<anonymous>
I have pasted the exact code mentioned in the doc still it is not working. Can anyone help me in identifying what I am missing here.
I dug around in the library and noticed that we are exporting several objects and our example is no longer correct.
To get the client you need to change your syntax a little bit to get the correct object.
const {FusionAuthClient} = require('fusionauth-node-client');
This translates to: require the library fusionauth-node-client and give me the FusionAuthClient from inside it. There are also a RESTClient and JWTManager available in the library but you shouldn't need either of those to code with FusionAuth.
I will also update our example to correct this discrepancy.

Why I get the error: "Attempted to unrender a fragment that was not rendered" when migrating from ractive.js 0.3.9 to 0.5.5

I have a long, complex and a little dirty set of templates that works OK in 0.3.9 but not in 0.5.5 where I get the error: "Attempted to unrender a fragment that was not rendered".
My template is very complex but I could reproduce a slice that works in 0.3.9 but not in 0.5.5.
This is how it works OK in 0.3.9: http://jsfiddle.net/Katio/ujx2e/
This template in 0.5.5 shows the mentioned error: http://jsfiddle.net/Katio/W3Lus/
Attempted to unrender a fragment that was not rendered
Edit 1:
Thaylon has opened an issue in Ractive project on Github:
https://github.com/ractivejs/ractive/issues/1003
I must admit I'm not sure what the root of the problem is.
Yet, change the beginning of line 33 in your template from:
{{^.responsable}}<span class="redOutline" data-validationmess="Solicitud ({{num+1}}) '{{../../nombreSubdata.values[0]}}', sección '{{nombre.values[0]}}', responsable no asignado.">(responsable no asignado)</span>{{/.responsable}}
to:
{{^responsable}}<span class="redOutline" data-validationmess="Solicitud ({{num+1}}) '{{../../nombreSubdata.values[0]}}', sección '{{nombre.values[0]}}', responsable no asignado.">(responsable no asignado)</span>{{/responsable}}
and it will render.
http://jsfiddle.net/W3Lus/2/
Edit
A pretty minimal example that exhibits the error is: http://jsfiddle.net/W3Lus/9/
Removing any part, even the static <option>, it will render.
Doesnt look like you're doing anything wrong, seems to be a bug.
Edit
I assume binding the select value to {{.responsable}}, when it does not resolve to anything, causes this, as long as there is any option in the select that actually would be bound to the non-existing value.
Edit
Minimal examples with different buggy results:
http://jsfiddle.net/W3Lus/13/
http://jsfiddle.net/W3Lus/12/
One wont render at all, the other wont render a part that it should.

Append database record in HTML5 builder fatal error

I have some code in my application:
$dmMain->tblOrgList->append();
This code written with auto-completion, so everything is correct.
But, when I trying to execute this code, I have error:
Fatal error: Call to a member function append() on a non-object in
C:\Users\ASAP\Documents\HTML5 Builder\Projects\VitoOrgList\index.php
on line 18
Can somebody advice, where I can find a trouble?
Thanks
I found the solution.
Really, I have no big PHP experience :-]
I just added before calling $dmMain methods in function body:
global $dmMain;

Testing Backbone Model with Jasmine and Sinon - Object #<Object> has no method 'spy'

I am trying to learn how to use Jasmine and Sinon for testing a Backbone application, and I was following this tutorial. Nevertheless, I ran into a problem that I don't know how to solve.
Most likely the solution is simple, but I need some guidance ...
In my project.spec.js file this is the code that is giving the problem:
it("should not save when name is empty", function() {
var eventSpy = sinon.spy();
this.project.bind("error", eventSpy);
this.project.save({"name": ""});
expect(this.eventSpy.calledOnce).toBeTruthy();
expect(this.eventSpy.calledWith(
this.project,
"cannot have an empty name"
)).toBeTruthy();
});
And this is the specific error that can be seen in the browser:
Failing 1 spec
7 specs | 1 failing
Project model should not save when name is empty.
TypeError: Object #<Object> has no method 'spy'
TypeError: Object #<Object> has no method 'spy'
at null.<anonymous> (http://localhost:8888/__spec__/models/project.spec.js:53:26)
at jasmine.Block.execute (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1024:15)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2025:31)
at jasmine.Queue.start (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:1978:8)
at jasmine.Spec.execute (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2305:14)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2025:31)
at onComplete (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2021:18)
at jasmine.Suite.finish (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2407:5)
at null.onComplete (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2451:10)
at jasmine.Queue.next_ (http://localhost:8888/__JASMINE_ROOT__/jasmine.js:2035:14)
In addition to the sinon.js library, I have installed the jasmine-sinon.js library (both are in the vendor/assets/javascripts folder and are included in the application.js file).
Thank you,
Alexandra
I faced this problem when I downloaded sinon.js file from GitHub (without Sinon folder). I solved the problem by downloading the library from http://sinonjs.org/
I'm going to post this as an answer, based on the comment thread above. We've narrowed down the problem to the line where sinon.spy() is called, so it's not specific to this test but to how sinon is being loaded.
I suspect the problem is that you're including sinon and jasmine-sinon in application.js, when they should really go in spec/javascripts/spec.js (in the same format). Try changing that and see if anything changes.
UPDATE:
Based on the comment thread below, it seems the code is getting to the this.project.save(...) line but the validations aren't working: I know this because if you're getting a POST error in the console, it means that backbone actually made the request (which it should not have because the name is empty). So you should go back and check the code you are actually testing.
I know this thread is old, but I had a similar issue today with this when going through this tutorial http://tinnedfruit.com/2011/03/25/testing-backbone-apps-with-jasmine-sinon-2.html. It looks like Backbone made a change and it calls the 'invalid' event when invalid model data is provided, not 'error'.
If you run into this error try changing:
it("should not save when name is empty", function() {
...
this.project.bind("error", eventSpy);
...
});
To:
it("should not save when name is empty", function() {
...
this.project.bind("invalid", eventSpy);
...
});
This resolved the issue for me.