-
Notifications
You must be signed in to change notification settings - Fork 10
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
updates seem slow #7
Comments
@Talor-A can you post the code to reproduce the slowness you're seeing? Also, have you tried the same realm.write/re-render code without In my experience I have noticed that realm can be noticeably slower in development than in a release build, especially with large data sets. That being said, if there's an issue here I would love to know and address it quickly. |
@jasonmerino I'll try to compare without react-native-realm. Here's the code I'm using, it's pretty similar to the example, but in todo list form: TodoContainerclass TodoContainer extends React.Component<Props, State> {
render() {
const {item} = this.props
return <Todo
title={item.title}
done={item.done}
navigation={this.props.navigation}
onPressDone={this.props.onPressDone}
/>
}
}
export default connectRealm(TodoContainer, {
schemas: ['Task'],
mapToProps(results, realm, ownProps) {
const item = results.tasks.find(i => i.id === ownProps.navigation.state.params.item.id)
return {
realm,
item,
onPressDone: val => setDone(item, val)
}
}
}) HomeContainerclass HomeContainer extends React.Component<Props, State> {
render() {
return <Home navigation={this.props.navigation} list={this.props.todos} onPressAdd={this.props.onPressAdd} />
}
}
export default connectRealm(HomeContainer, {
schemas: ['Task'],
mapToProps(results, realm) {
return {
realm,
todos: results.tasks || [],
onPressAdd: () => {
const randomNum = Math.floor(Math.random() * 100000).toString()
realm.write(() => realm.create('Task', {
id: randomNum,
title: 'Todo #' + randomNum,
}))
}
}
}
}
) these are just the container components. my problem is coming from the |
@Talor-A from the code you posted I'm not seeing anything that would cause a bottleneck or any slowness. However, it doesn't look like all the code you're using isn't here and it's probably not enough to get a super accurate reproduction case going. I have noticed that sometimes managing the state of Have you had a chance to write the same logic without this library to see if there's a difference in the time it takes to do the update? |
sorry if it wasn't clear, the problem is similar to what you're saying - the |
Hi, is there a reason there's a delay between doing a
realm.write(()=>{})
and the component updating? does this persist in production mode? thanks.The text was updated successfully, but these errors were encountered: