protected void SetState(Func <TState, TProps, TState> updater, Action callback) { Func <WrappedValue <TState>, WrappedValue <TProps>, WrappedValue <TState> > wrappedUpdater = (prevState, props) => { var unwrappedPrevState = ComponentPropsHelpers.UnWrapValueIfDefined(prevState); var unwrappedProps = ComponentPropsHelpers.UnWrapValueIfDefined(props); return(new WrappedValue <TState> { Value = updater(unwrappedPrevState, unwrappedProps) }); }; Script.Write("this.setState(wrappedUpdater, callback)"); }
private bool ShouldComponentUpdate(WrappedValue <TProps> nextPropsIfAny) { return(!ComponentPropsHelpers.DoPropsReferencesMatch(this.props, ComponentPropsHelpers.UnWrapValueIfDefined(nextPropsIfAny))); }
private void ComponentDidUpdate(WrappedValue <TProps> previousProps) { ComponentDidUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(previousProps)); }
private void ComponentWillUpdate(WrappedValue <TProps> nextProps) { ComponentWillUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(nextProps)); }
// These are the life cycle methods that React calls - they have to unwrap the props and state references (if provided) in order to pass them on to the methods above // (the life cycle methods that derived classes may make use of) private void ComponentWillReceiveProps(WrappedValue <TProps> nextPropsIfAny) { ComponentWillReceiveProps(ComponentPropsHelpers.UnWrapValueIfDefined(nextPropsIfAny)); }
private bool ShouldComponentUpdate(WrappedValue <TProps> nextPropsIfAny, WrappedValue <TState> nextStateIfAny) { return(ShouldComponentUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(nextPropsIfAny), ComponentPropsHelpers.UnWrapValueIfDefined(nextStateIfAny))); }