Пример #1
0
        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)");
        }
Пример #2
0
 private bool ShouldComponentUpdate(WrappedValue <TProps> nextPropsIfAny)
 {
     return(!ComponentPropsHelpers.DoPropsReferencesMatch(this.props, ComponentPropsHelpers.UnWrapValueIfDefined(nextPropsIfAny)));
 }
Пример #3
0
 private void ComponentDidUpdate(WrappedValue <TProps> previousProps)
 {
     ComponentDidUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(previousProps));
 }
Пример #4
0
 private void ComponentWillUpdate(WrappedValue <TProps> nextProps)
 {
     ComponentWillUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(nextProps));
 }
Пример #5
0
 // 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));
 }
Пример #6
0
 private bool ShouldComponentUpdate(WrappedValue <TProps> nextPropsIfAny, WrappedValue <TState> nextStateIfAny)
 {
     return(ShouldComponentUpdate(ComponentPropsHelpers.UnWrapValueIfDefined(nextPropsIfAny), ComponentPropsHelpers.UnWrapValueIfDefined(nextStateIfAny)));
 }