001package react4j; 002 003import javax.annotation.Nonnull; 004import javax.annotation.Nullable; 005import jsinterop.annotations.JsOverlay; 006import jsinterop.annotations.JsPackage; 007import jsinterop.annotations.JsProperty; 008import jsinterop.annotations.JsType; 009 010/** 011 * Native interface to native runtime for creating views. 012 */ 013@JsType( isNative = true, namespace = JsPackage.GLOBAL, name = "React" ) 014public final class React 015{ 016 private React() 017 { 018 } 019 020 /** 021 * Return true if views should have human readable names specified. 022 * Useful if you want to interact via DevTools or other tool chains. 023 * 024 * @return true to enable human readable names for views. 025 */ 026 @JsOverlay 027 public static boolean enableViewNames() 028 { 029 return ReactConfig.enableViewNames(); 030 } 031 032 /** 033 * Return true if the input keys should be minimized. 034 * This will significantly reduce the size of the compiled output but will make inspecting the inputs 035 * in DevTools difficult if not impossible. 036 * 037 * @return true to minimize input keys. 038 */ 039 @JsOverlay 040 public static boolean shouldMinimizeInputKeys() 041 { 042 return ReactConfig.shouldMinimizeInputKeys(); 043 } 044 045 /** 046 * Return true if the input value should be validated when initially set or when changed. 047 * 048 * @return true to validate input values. 049 */ 050 @JsOverlay 051 public static boolean shouldValidateInputValues() 052 { 053 return ReactConfig.shouldValidateInputValues(); 054 } 055 056 /** 057 * Return true if react state should be used to store debug data. 058 * Useful if you want to inspect the debug data via DevTools. This feature is resource intensive 059 * and should not be enabled in production. 060 * 061 * @return true if react state should be used to store debug data. 062 */ 063 @JsOverlay 064 public static boolean shouldStoreDebugDataAsState() 065 { 066 return ReactConfig.shouldStoreDebugDataAsState(); 067 } 068 069 /** 070 * Return true if invariants will be checked. 071 * 072 * @return true if invariants will be checked. 073 */ 074 @JsOverlay 075 public static boolean shouldCheckInvariants() 076 { 077 return ReactConfig.shouldCheckInvariants(); 078 } 079 080 /* 081 * WARNING: The following symbols are all imported from react which involves manually patching the js files 082 * for each react release. We do this rather than trying to redefine them as Elemental2 does not correctly 083 * model Symbol and we would still have to use primitive integer abstraction for IE11 anyway. 084 */ 085 /** 086 * The Symbol type for Fragments. 087 */ 088 @JsProperty( name = "Fragment" ) 089 static Object Fragment; 090 /** 091 * The Symbol type for StrictMode. 092 */ 093 @JsProperty( name = "StrictMode" ) 094 static Object StrictMode; 095 /** 096 * The Symbol type for Suspense. 097 */ 098 @JsProperty( name = "Suspense" ) 099 static Object Suspense; 100 /** 101 * The Symbol type for Element. 102 */ 103 @JsProperty( name = "Element" ) 104 static Object Element; 105 106 /** 107 * Creates a context with specified default value. 108 * 109 * @param <T> the type of the context. 110 * @param defaultValue the default value. 111 * @return the context. 112 */ 113 @Nonnull 114 static native <T> Context<T> createContext( T defaultValue ); 115 116 /** 117 * Return the fiber for current component. 118 * This can return null when not called from within the render method of a component. 119 */ 120 @JsProperty( name = "React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner.current", namespace = JsPackage.GLOBAL ) 121 @Nullable 122 static native Object currentOwner(); 123}