[GH-ISSUE #143] SetInterval() doesn't work properly #86

Closed
opened 2026-05-05 11:40:16 -06:00 by gitea-mirror · 4 comments
Owner

Originally created by @jakubtelec on GitHub (May 22, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/143

Problem: SetInterval() seems to work only when mouse cursor is moving inside app's window.

(also: strange comma appears in the middle of <Text> component)

Os: Windows 10 and Ubuntu 16.04

How does it look like:

SetInterval bug recording

Code:

import React, { Component } from 'react'
import { render, Window, App, Text } from 'proton-native'

class Example extends Component {
  constructor(props) {
    super(props)
    this.state = {
      seconds: 0,
    }
  }

  componentDidMount() {
    this.timerID = setInterval(() => this.tick(), 1000)
  }

  componentWillUnmount() {
    clearInterval(this.timerID)
  }

  tick() {
    this.setState((prevState, props) => ({
      seconds: prevState.seconds + 1
    }))
  }
  render() {
    return (
      <App>
        <Window size={{ w: 150, h: 150 }} menuBar={false} margined>
          <Text> Timer: {this.state.seconds}</Text>
        </Window>
      </App>
    )
  }
}

render(<Example />)
Originally created by @jakubtelec on GitHub (May 22, 2018). Original GitHub issue: https://github.com/kusti8/proton-native/issues/143 **Problem**: SetInterval() seems to work only when mouse cursor is moving inside app's window. (also: strange comma appears in the middle of `<Text>` component) **Os**: Windows 10 and Ubuntu 16.04 **How does it look like:** ![SetInterval bug recording](https://image.ibb.co/fJJXT8/proton_app.gif) **Code:** ```javascript import React, { Component } from 'react' import { render, Window, App, Text } from 'proton-native' class Example extends Component { constructor(props) { super(props) this.state = { seconds: 0, } } componentDidMount() { this.timerID = setInterval(() => this.tick(), 1000) } componentWillUnmount() { clearInterval(this.timerID) } tick() { this.setState((prevState, props) => ({ seconds: prevState.seconds + 1 })) } render() { return ( <App> <Window size={{ w: 150, h: 150 }} menuBar={false} margined> <Text> Timer: {this.state.seconds}</Text> </Window> </App> ) } } render(<Example />) ```
Author
Owner

@parro-it commented on GitHub (May 22, 2018):

What version are you using? That problem should be solved in last version that use 0.2.0 version of libui-node

<!-- gh-comment-id:391134382 --> @parro-it commented on GitHub (May 22, 2018): What version are you using? That problem should be solved in last version that use 0.2.0 version of libui-node
Author
Owner

@mischnic commented on GitHub (May 22, 2018):

That problem should be solved in last version that use 0.2.0 version of libui-node

No. startLoop is only called in render(<Example />). So before, the node's setTimeout is used when declaring the component functions.

<!-- gh-comment-id:391134819 --> @mischnic commented on GitHub (May 22, 2018): > That problem should be solved in last version that use 0.2.0 version of libui-node No. `startLoop` is only called in `render(<Example />)`. So before, the node's `setTimeout` is used when declaring the component functions.
Author
Owner

@parro-it commented on GitHub (May 22, 2018):

No. startLoop is only called in render(). So before, the node's setTimeout is used when declaring the component functions.

Oh, yes, we didn't think of this use case... I don't know how we can solve it, but the napi version should not have this problem anymore. Or we can also back port the fix in event loop to version 0.3.0

<!-- gh-comment-id:391135750 --> @parro-it commented on GitHub (May 22, 2018): > No. startLoop is only called in render(<Example />). So before, the node's setTimeout is used when declaring the component functions. Oh, yes, we didn't think of this use case... I don't know how we can solve it, but the napi version should not have this problem anymore. Or we can also back port the fix in event loop to version 0.3.0
Author
Owner

@jakubtelec commented on GitHub (May 28, 2018):

After update SetInterval() works fine, so I'm closing the issue.

<!-- gh-comment-id:392610329 --> @jakubtelec commented on GitHub (May 28, 2018): After update SetInterval() works fine, so I'm closing the issue.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/proton-native#86
No description provided.