Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UseSignal<SENDER, ARGS>

UseSignal provides a way to hook up a Phosphor signal to a React element, so that the element is re-rendered every time the signal fires.

It is implemented through the "render props" technique, using the children prop as a function to render, so that it can be used either as a prop or as a child of this element https://reactjs.org/docs/render-props.html

Example as child:

function LiveButton(isActiveSignal: ISignal<any, boolean>) {
 return (
   <UseSignal signal={isActiveSignal} initialArgs={True}>
    {(_, isActive) => <Button isActive={isActive}>}
   </UseSignal>
 )
}

Example as prop:

function LiveButton(isActiveSignal: ISignal<any, boolean>) {
 return (
   <UseSignal
     signal={isActiveSignal}
     initialArgs={True}
     children={(_, isActive) => <Button isActive={isActive}>}
   />
 )
}

Type parameters

  • SENDER

  • ARGS

Hierarchy

Index

Constructors

constructor

  • Type parameters

    • SENDER

    • ARGS

    Parameters

    Returns UseSignal

Properties

context

context: any

If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

static contextType = MyContext
// For TS pre-3.7:
context!: React.ContextType<typeof MyContext>
// For TS 3.7 and above:
declare context: React.ContextType<typeof MyContext>
see

https://reactjs.org/docs/context.html

Readonly props

props: Readonly<P> & Readonly<{ children?: ReactNode }>

refs

refs: {}

Type declaration

Private slot

slot: any

state

state: Readonly<S>

Optional Static contextType

contextType: Context<any>

If set, this.context will be set at runtime to the current value of the given Context.

Usage:

type MyContext = number
const Ctx = React.createContext<MyContext>(0)

class Foo extends React.Component {
  static contextType = Ctx
  context!: React.ContextType<typeof Ctx>
  render () {
    return <>My context's value: {this.context}</>;
  }
}
see

https://reactjs.org/docs/context.html#classcontexttype

Methods

Optional UNSAFE_componentWillMount

UNSAFE_componentWillMount:

Optional UNSAFE_componentWillReceiveProps

UNSAFE_componentWillReceiveProps:

Optional UNSAFE_componentWillUpdate

UNSAFE_componentWillUpdate:

Optional componentDidCatch

componentDidCatch:

componentDidMount

  • componentDidMount(): void
  • Returns void

Optional componentDidUpdate

componentDidUpdate:

Optional componentWillMount

componentWillMount:

Optional componentWillReceiveProps

componentWillReceiveProps:

componentWillUnmount

  • componentWillUnmount(): void
  • Returns void

Optional componentWillUpdate

componentWillUpdate:

forceUpdate

  • forceUpdate(callback?: () => void): void
  • Parameters

    • Optional callback: () => void
        • (): void
        • Returns void

    Returns void

Optional getSnapshotBeforeUpdate

getSnapshotBeforeUpdate:

render

  • render(): React.ReactNode
  • Returns React.ReactNode

setState

  • setState<K>(state: ((prevState: Readonly<S>, props: Readonly<P>) => Pick<S, K> | S | null) | (Pick<S, K> | S | null), callback?: () => void): void
  • Type parameters

    • K: "value"

    Parameters

    • state: ((prevState: Readonly<S>, props: Readonly<P>) => Pick<S, K> | S | null) | (Pick<S, K> | S | null)
    • Optional callback: () => void
        • (): void
        • Returns void

    Returns void

Optional shouldComponentUpdate

shouldComponentUpdate:

Generated using TypeDoc