All Downloads are FREE. Search and download functionalities are using the official Maven repository.

react4j.arez.spy.ReactArezConsoleSpyEventProcessor Maven / Gradle / Ivy

package react4j.arez.spy;

import arez.browser.extras.spy.ConsoleSpyEventProcessor;
import arez.browser.extras.spy.StringifyReplacer;
import java.util.Arrays;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;

/**
 * A customized console event processor that avoids accessing "key" and "ref" attributes.
 * This causes warnings when accessing props.key and props.ref in react components.
 */
public class ReactArezConsoleSpyEventProcessor
  extends ConsoleSpyEventProcessor
{
  /**
   * {@inheritDoc}
   */
  @Nonnull
  @Override
  protected StringifyReplacer getStringifyReplacer()
  {
    return new StringifyReplacer()
    {
      @Nonnull
      @Override
      protected String[] getPropertyNames( @Nonnull final Object object )
      {
        return Arrays.stream( super.getPropertyNames( object ) ).
          filter( n -> !n.equals( "key" ) && !n.equals( "ref" ) ).
          collect( Collectors.toList() ).
          toArray( new String[ 0 ] );
      }
    };
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy