-
Notifications
You must be signed in to change notification settings - Fork 24.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom View Data (iOS) #3165
Comments
Fascinating find... thanks for reporting with these details. Could you share some of your JS and Obj-C code that you use to export the custom view? I'm curious if there is an issue with the propDiffer on the JS side or something else. |
Of course! I'll try to capture the important parts here. The chartData is the data I specified in the my first comment. An array of arrays. import React from 'react-native';
const {
Component,
PropTypes,
requireNativeComponent,
View
} = React;
const NativeMyCustomView = requireNativeComponent('ChartView', MyCustomView);
class MyCustomView extends Component {
static displayName = 'ChartView';
static propTypes = {
data: PropTypes.array,
options: PropTypes.object,
style: View.propTypes.style
};
constructor (props) {
super(props);
}
render () {
return (
<NativeMyCustomView
data={this.props.data}
options={this.props.options}
style={this.props.style} />
);
}
}
module.exports = MyCustomView;
That is all of the spots where the data is used and passed around to. |
I can finally close this. Just revisited and the issue doesn't seem to be there anymore. |
I have a custom view that accepts some data as a property and feeds that into a native iOS charting library. While passing the props through I noticed a significant drop in performance. If I use hard coded data within the chart render function it renders in 40ms, once I attempt to pass the data through my custom view it takes 2400ms. The data looks like this:
data = [ [0, 1], [1, 2], ..., [2, 2]];
If I convert this into an array of objects and pass the exact same data through the performance issue is gone. The new data format looks like this and the render time is back to 40ms:
data = [ {value1: 0, value2: 1}, {value1: 1, value2: 2}, ..., {value1: 2, value2: 2}];
If I try to use an array of objects with numerical keys the problem arises again. This is problematic data with equivalent performance to the array of arrays:
data = [ {'1': 0, '2': 1}, {'1': 1, '2': 2}, ..., {'1': 2, '2': 2}];
I'm not sure if this is an issue on the iOS side or the React Native side. Is this a known problem when passing data through the bridge? Ideally, I would not have to map my arrays into objects so I was hoping someone had some insight on this scenario. Also for this specific scenario the array is only 365 indices.
The text was updated successfully, but these errors were encountered: