flowr

  • Docs
  • Examples
Docs Menu
  • Getting started
  • Conditionals
    • Maybe
    • Either
    • Flip
    • Reverse
    • Order
    • One
    • Some
    • Constant
    • Just
    • Nothing
    • Pure
  • Schedulers
    • Await
    • Stream
    • Delay
    • Debounce
    • Throttle

Pure

import { Pure } from 'flowr';

Pure wraps it's children in a component that implements shouldComponentUpdate. Whatever props you provide to Pure will be compared for shallow equality and determine if the component should update. None of the props will be passed down to the children.

Pure will ignore the children when comparing props
// ...
state = { count: 0, label: 'started at' }

componentDidMount() {
  setInterval(this.increment, 1000)
}

increment = () => {
  this.setState(({ count }) => ({
    count: count + 1
  }))
}

render() {
  const { count, label } = this.state
  return (
    
{label}: {count}
) }

In the above example, we are incrementing the count and updating state with the new value each second. Because Pure only "listens" for the label, it won't update unless we actually change state.label. When we do that, it will update the children with the new label and count.

Props

NameTypeDefaultDescription
***Accepts any props, the scope is to just compare them in order to determine updates

Contribute on Github! Edit this section.