Skip to content

stop

Method to stop rendering updates for the Signify instance.

Description

The stop method temporarily disables re-rendering for components that use this Signify state. State changes will still be tracked internally, but connected React components won't re-render until resume() is called.

Input/Output

InputTypeDescription
None-No parameters required
OutputTypeDescription
ReturnsvoidNo return value

Example

typescript
import { signify } from 'react-signify';
import React from 'react';

const sCounter = signify(0);

function CounterComponent() {
  const count = sCounter.use();
  
  const performBatchUpdates = () => {
    // Stop rendering to prevent intermediate re-renders
    sCounter.stop();
    
    // Perform multiple updates
    sCounter.set(sCounter.value + 1);
    sCounter.set(sCounter.value + 1);
    sCounter.set(sCounter.value + 1);
    
    // Resume rendering - component will re-render once with final value
    sCounter.resume();
  };
  
  return (
    <div>
      <p>Count: {count}</p>
      <button onClick={performBatchUpdates}>
        Add 3 (Batched)
      </button>
      <button onClick={() => sCounter.stop()}>
        Stop Updates
      </button>
    </div>
  );
}

Released under the MIT License.