Skip to content

Files

Latest commit

 

History

History

phaseI

Phase I

finish reconciler bindings

Steps

Fill out the rest of the reconciler lifecycle methods

getPublicInstance

getPublicInstance(instance: Instance | TextInstance): PublicInstance {
  return instance;
}

prepareForCommit

prepareForCommit(_containerInfo: Container): void {
  // noop
}

prepareUpdate

prepareUpdate(
  _instance: Instance,
  _type: Type,
  _oldProps: Props,
  _newProps: Props,
  _rootContainerInstance: Container,
  _hostContext: HostContext
): null | UpdatePayload {
  return true;
}

resetAfterCommit

resetAfterCommit(_containerInfo: Container): void {
  // noop
}

finalizeInitialChildren

finalizeInitialChildren(
  _parentInstance: Instance,
  _type: Type,
  _props: Props,
  _rootContainerInstance: Container,
  _hostContext: HostContext
): boolean {
  return true;
}

commitUpdate

commitUpdate(
  instance: Instance,
  _updatePayload: any,
  _type: string,
  _oldProps: Props,
  newProps: Props
): void {
  return instance.commitUpdate(newProps);
}

commitMount

commitMount(instance: Instance, _type: Type, _newProps: Props): void {
  instance.commitMount();
}

shouldDeprioritizeSubtree

shouldDeprioritizeSubtree(): boolean {
  return true;
}

scheduleDeferredCallback

scheduleDeferredCallback(
  callback?: () => any,
  _options?: { timeout: number }
): any {
  if (callback) {
    throw new Error(
      'Scheduling a callback twice is excessive. Instead, keep track of ' +
        'whether the callback has already been scheduled.'
    );
  }
}

cancelDeferredCallback

cancelDeferredCallback(_callbackID: any): void {
  // noop
}

setTimeout

setTimeout(
  handler: (...args: any[]) => void,
  timeout: number
): TimeoutHandle | NoTimeout {
  return setTimeout(handler, timeout);
}

clearTimeout

clearTimeout(handle: TimeoutHandle | NoTimeout): void {
  return clearTimeout(handle);
}

Interesting Files

src/reconciler.ts

Demo

npm run start