React Native slice() function undefined error - react-native

I want to update my listview row for that I am trying to slice listview datasource but its raising below error:
this.state.dataSource.slice is not a function. (In
'this.state.dataSource.slice()', 'this.state.dataSource.slice' is
undefined)
And here is my code:
let newArray = this.state.dataSource.slice();
newArray[indexToUpdate] = {
//Here I am updating my values.
};
this.setState({
dataSource: this.state.dataSource.cloneWithRows(newArray),
});
Let me know if there is any error in my code or something wrong I have done.

this.state.dataSource is not an Array, that's why you cant do slice() on dataSource. It looks like this
{ _rowHasChanged: [Function: rowHasChanged],
_getRowData: [Function: defaultGetRowData],
_sectionHeaderHasChanged: [Function],
_getSectionHeaderData: [Function: defaultGetSectionHeaderData],
_dataBlob: { s1: [ 'row 1', 'row 2' ] },
_dirtyRows: [ [ true, true ] ],
_dirtySections: [ true ],
_cachedRowCount: 2,
rowIdentities: [ [ '0', '1' ] ],
sectionIdentities: [ 's1' ]
}
Your required array is in _dataBlob key of that object.
Note: it's working fine and updates listview dataSource using below line
this.state.dataSource._dataBlob.s1.slice()

Related

How To Set serializableCheck: false For Specific Slice ReduxToolKit React Native

I cannot find a way to set serializableCheck to false only for specific slice.
const store = configureStore({
reducer: {
ApiSignalMenu: ApiSignalMenuSlice.reducer,
ApiSignalData: ApiSignalDataSlice.reducer,
ApiHistoricalMenu: ApiHistoricalMenuSlice.reducer,
ApiHistoricalYearData: ApiHistoricalYearDataSlice.reducer,
ApiUpProbabilityMenu: ApiUpProbabilityMenuSlice.reducer,
ApiUpProbabilityData: ApiUpProbabilityDataSlice.reducer,
ApiMoverData: ApiMoverDataSlice.reducer,
ApiChartingMenu: ApiChartingMenuSlice.reducer,
ApiChartingData: ApiChartingDataSlice.reducer,
ApiTicker: ApiTickerSlice.reducer
},
// middleware: (getDefaultMiddleware) =>
// getDefaultMiddleware({
// serializableCheck: false
// }
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
serializableCheck: {
ignoredPaths: ['ApiMoverData.apiData.0'],
}
})
});
I have array data in : ApiMoverData
If I set : ignoredPaths: ['ApiMoverData.apiData.0'],
Then I got error again for A non-serializable value was detected in an action, in the path: payload.0. Value:, ApiMoverData
And
Then I got error again for Then I got error again for A non-serializable value was detected in the state, in the path: ApiMoverData.apiData.0
ApiMoverData.apiData.1, Then ApiMoverData.apiData.2, again.
How to set serializableCheck to false to all my array data in specific slice ?
This post : Is there a way to set the serializableCheck to false for one reducer only in redux?
did not tell a specific answer.
Thank You
EDIT :
My structure data looks like this :
Array [
ApiMoverData {
"change": "1,43",
"company": "Garuda Maintenance Facility Aero Asia Tbk.",
"id": 0,
"last": "71",
"ticker": "GMFI",
"value": "99.343.200",
"volume": "13.992",
},
ApiMoverData {
"change": "1,44",
"company": "Kimia Farma Tbk.",
"id": 1,
"last": "1.765",
"ticker": "KAEF",
"value": "956.208.000",
"volume": "5.433",
}
]
If I set : ignoredPaths: ['ApiMoverData.apiData']
Then I got error again for A non-serializable value was detected in an action, in the path: payload.0. Value:, ApiMoverData
And
Then I got error again for A non-serializable value was detected in the state, in the path: ApiMoverData.apiData.0
ApiMoverData.apiData.1, Then ApiMoverData.apiData.2, again.
Same Error
recomended by #phry do not use class instance in redux-toolkit. Because it will effect negative in future. Also we will not be able to use Redux-Persist. Just use non-class javascript object and store that.

Vue.js: How can I update an array of objects?

I am trying to update an array of objects in Vue.js. When trying to update the values of my location I am struggling to update the objects within an array.
When I log the objects out, I get this:
console.log(this.location) // {…}
console.log(this.location.additionalProperties); // [{…}, __ob__: Observer]
console.log(this.location.additionalProperties.integrations); // undefined
My additionalProperties object looks like this:
"additionalProperties": [
{
"integrations": [
{
"foo": {
"locationId": 123,
"example": "bar",
...
}
}
]
}
],
I am passing in my location as a props like this:
location: {
type: Object,
required: true,
default: () => ({}),
},
I know I am getting the location passed in correctly. I believe it is a syntax issue I am struggling with. I am trying to set my foo object to be something like this:
this.location.additionalProperties.integrations.foo = {
locationId: 456,
example: "testing",
somethingElse: "anotherValue"
}
Using the above, I'll get a version of cannot set foo of undefined. How can I update the object within the additionalProperties array?
Thank you for any suggestions!
additionalProperties is an array
"additionalProperties": [
{
"integrations": [
{
"foo": {
"locationId": 123,
"example": "bar",
...
}
}
]
}
],
this.location.additionalProperties[0].integrations.foo = ...

How to replace URL of Image in react native

I want to replace "file:/" to "file://" this.
I want to replace this code
FormData {
"_parts": Array [
Array [
"lead_tag_number",
"NAS00001",
],
Array [
"upload_pan_card_file",
Object {
"singleFile": "file:/data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FAwesomeProject-caa28295-07ae-40d0-8b07-905883f99373/ImagePicker/6853c307-087c-48be-9a23-3ac01db646d4.jpg",
},
],
],
}
to this code
FormData {
"_parts": Array [
Array [
"lead_tag_number",
"NAS00001",
],
Array [
"upload_pan_card_file",
Object {
"singleFile": "file://data/user/0/host.exp.exponent/cache/ExperienceData/%2540anonymous%252FAwesomeProject-caa28295-07ae-40d0-8b07-905883f99373/ImagePicker/6853c307-087c-48be-9a23-3ac01db646d4.jpg",
},
],
],
}
I am getting It in console when I print console.log(data). please help thanks
You can try this
let filename = "file://data/blablabla.jpg"
filename = filename.replace('file:/', 'file://');

Rally - Data Context and InlineFilter issue in a RallyGridBoard

Objective :
Trying to build a Rally App to populate "PortFolioItem/features" based upon a Project value selected from a userSearchCombo box.
Methodology:
1. Creating a UserSearchComboBox based upon the 'Project' model.
2. Depending upon the value selected from the combo box,Creating a TreeStore based on the model 'PortfolioItem/Feature'.
The context scoped for the tree Store is based on the value selected from the Project Search Combo Box
app.portfoliotreeStore = Ext.create('Rally.data.wsapi.TreeStoreBuilder').build({
models: modelNames,
autoLoad: true,
enableHierarchy: true,
limit: 'Infinity',
remoteSort: true,
// sorters: app.appSorters,
//fetch: ['Name', 'FormattedID', 'ScheduleState', 'PlanEstimate', 'Owner', 'Project'],
//filters: filters,
// filters: this.getQueryFilter(),
context: {
project: app.selProjectRef,
projectScopeDown: true
}
}).then({
success: this._addGridboard,
failure: this.showErrorNotification,
scope: this
});
In the Add grid Board Method ,created a gridBoard with some plugins
_addGridboard: function(store) {
console.log("Entering _addGridBoard", store);
app.portfoliotreeStore = store;
var modelNames = ['portfolioitem/PPMFeature']
var filters = app.getStoreFilters(app.selProjectName);
console.log("the Grid", app.down('#gridContainer'));
if (app.down('#gridContainer')) {
app.down('#gridContainer').remove('gridBoard');
}
//this.gridBoardConfig = app._getGridBoardConfig(store);
var dataContext = app.getContext().getDataContext();
console.log("DATA CONTEXT ::::", dataContext);
gridStateString = this.statePrefix + "-treegrid";
gridStateId = this.getContext().getScopedStateId(gridStateString);
app.down('#gridContainer').add({
xtype: 'rallygridboard',
itemId: 'gridBoard',
// context: this.getContext(),
modelNames: ['portfolioitem/PPMFeature'],
toggleState: 'grid',
plugins: [
'rallygridboardaddnew', {
ptype: 'rallygridboardinlinefiltercontrol',
inlineFilterButtonConfig: {
//stateful: true,
//stateId: this.getContext().getScopedStateId('filters-1'),
//collapsed: true,
context: this.getContext(),
modelNames: ['portfolioitem/PPMFeature'],
inlineFilterPanelConfig: {
collapsed: true,
quickFilterPanelConfig: {
whiteListFields: [
'Tags',
'Milestones'
],
defaultFields: [
'ArtifactSearch',
'Owner',
'ModelType',
'Milestones'
]
}
}
}
},
{
ptype: 'rallygridboardfieldpicker',
headerPosition: 'left',
modelNames: this._getModelNames()
//stateful: true,
//stateId: this.getContext().getScopedStateId('columns-example')
}
],
stateful: true,
listeners: {
'staterestore': {
fn: this._onGridStateRestore,
single: true
},
'load': {
fn: this._onGridload,
single: true
},
scope: this
},
gridConfig: {
store: store,
storeConfig: {
filters: this.getQueryFilter()
},
columnCfgs: [
'Name',
'Project',
'ScheduleState',
'Owner',
'PlanEstimate'
]
// derivedColumns: this.getDerivedColumns()
},
/*
gridConfig: {
store: store,
storeConfig: {
filters: this.getQueryFilter()
},
columnCfgs: [
'Name',
'Project',
'ScheduleState',
'Owner',
'PlanEstimate'
],
// derivedColumns: this.getDerivedColumns()
},
*/
height: this.getHeight()
});
},
Please Note the following
Not passing any context to the grid component - Reason:: if i pass
"this.getContext" to the Grid, duplicates records are initially loaded into
the grid , once i click on any header to sort the grid,the duplicates disappear.
Issue: catch 22 Situation
The only way for me to get rid of the duplicates is to not pass the context to the GridBoard, However this impacts my Plugin - "rallygridboardinlinefiltercontrol"
if i scroll over my InlinefilterButton , it throws this error
Uncaught TypeError: Cannot read property 'collapsed' of undefined
at constructor._onBeforeShowToolTip (VM556 sdk.js:100)
at constructor.fire (VM556 sdk.js:5)
at constructor.continueFireEvent (VM556 sdk.js:6)
at constructor.fireEventArgs (VM556 sdk.js:6)
at constructor.prototype.fireEventArgs (VM556 sdk.js:18)
at constructor.fireEvent (VM556 sdk.js:6)
at constructor.show (VM556 sdk.js:15)
at constructor.callParent (VM556 sdk.js:2)
at constructor.show (VM556 sdk.js:25)
at constructor.showFromDelay (VM556 sdk.js:25)
And when i Click on it , it Throws this Error
Uncaught TypeError: Cannot read property 'toggleCollapse' of undefined
at constructor._toggleFilterPanel (VM556 sdk.js:100)
at call (VM556 sdk.js:5)
It does not impact my other filters
Ok , I finally found the Issue ... It appears , i need to pass the Context to the grid , but i also need to switch the autoload on the TreeGrid to false , this is because the plugin owns the responsibility of loading the store .... YAY !! Eureka Eureaka I got this ... Can any one sugest any good book on Rally..

Display all associated children with wsapi.Store

I've been searching for a way to display all the defects for a project and it's
children in Rally, however I can't seem to find the right way to go about this.
In the constructor it seems there is no parent property, however I've seen this property used in previous versions using wsapiStore. What is the correct way of doing this now?
Here's a look at my code:
config.json:
{
"name": "BasicRallyGrid",
"className": "CustomApp",
"server": "https://rally1.rallydev.com",
"sdk": "2.1",
"javascript": [
"App.js"
],
"css": [
"app.css"
]
}
Call to Store:
this.myStore= Ext.create('Rally.data.wsapi.Store', {
model: 'Defect',
autoLoad: true,
filters: myFilters,
/*filters: Ext.create('Rally.data.wsapi.Filter', {
property: 'Parent',
operator: '=',
value: "SomeParent"
}),
listeners: {
load: function (myStore) {
if (!this.myStore) {
this._createGrid(myStore);
}
},
scope: this
},
fetch: ['FormattedID', 'Name', 'Severity', 'Iteration', 'Project']
});
}
},
My Grid code:
_createGrid: function (myStore) {
this.myGrid = Ext.create('Rally.ui.grid.Grid', {
store: myStore,
columnCfgs: [
'FormattedID', 'Name', 'Severity', 'Iteration', 'Project'
]
});
this.add(this.myGrid);
Any help would be greatly appreciated. Also, as this is my first question here, if I broke some etiquette please let me know so I can avoid it in future posts.
Thank you!
You just need to use project scoping... Check out this guide: https://help.rallydev.com/apps/2.1/doc/#!/guide/data_stores-section-scoping
By default your store will inherit your global scoping, so I would have expected it to just work, but depending on what you're doing you may have to explicitly specify your project scope + up/down.