You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// /// Isomorphic helper function for Fable.Core.JsInterop.import,
49
+
// /// it works exactly the same as import in client side, but would return Unchecked.defaultof<'T> in server side instead of throw an runtime error immediately
50
+
// [<Emit("""import "$1" from "$2" """)>]
51
+
// let inline importOrDefault<'T> selector path =
52
+
// Unchecked.defaultof<'T>
53
+
54
+
// /// Isomorphic helper function for Fable.Core.JsInterop.importAll,
55
+
// /// it works exactly the same as importAll in client side, but would return Unchecked.defaultof<'T> in server side instead of throw an runtime error immediately
56
+
// let inline importAllOrDefault<'T> path =
57
+
// importOrDefault<'T> "*" path
58
+
59
+
60
+
61
+
// /// Isomorphic helper function for Fable.Core.JsInterop.importDefault,
62
+
// /// it works exactly the same as importDefault in client side, but would return Unchecked.defaultof<'T> in server side instead of throw an runtime error immediately
63
+
// let inline importDefaultOrDefault<'T> path =
64
+
// importOrDefault<'T> "default" path
65
+
66
+
// /// Isomorphic helper function for Fable.Core.JsInterop.importSideEffects,
67
+
// /// it works exactly the same as importSideEffects in client side, but would ignore in server side instead of throw an runtime error immediately
member valchildren:ReactElement array =[||]with get, set
86
85
87
86
[<Emit("$0.state")>]
88
-
member__.state:'S =jsNative
87
+
member valstate:'S =Unchecked.defaultof<'S>with get, set
89
88
90
89
/// ATTENTION: Within the constructor, use `setInitState`
91
90
/// Enqueues changes to the component state and tells React that this component and its children need to be re-rendered with the updated state. This is the primary method you use to update the user interface in response to event handlers and server responses.
92
91
/// Think of setState() as a request rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. React does not guarantee that the state changes are applied immediately.
93
92
/// setState() does not always immediately update the component. It may batch or defer the update until later. This makes reading this.state right after calling setState() a potential pitfall. Instead, use componentDidUpdate or a setState callback (setState(updater, callback)), either of which are guaranteed to fire after the update has been applied. If you need to set the state based on the previous state, read about the updater argument below.
94
93
/// setState() will always lead to a re-render unless shouldComponentUpdate() returns false. If mutable objects are being used and conditional rendering logic cannot be implemented in shouldComponentUpdate(), calling setState() only when the new state differs from the previous state will avoid unnecessary re-renders.
95
94
[<Emit("$0.setState($1)")>]
96
-
member__.setState(value:'S):unit =jsNative
95
+
memberx.setState(value:'S):unit =x.state <- value
97
96
98
97
/// Overload of `setState` accepting updater function with the signature: `(prevState, props) => stateChange`
99
98
/// prevState is a reference to the previous state. It should not be directly mutated. Instead, changes should be represented by building a new object based on the input from prevState and props.
100
99
/// Both prevState and props received by the updater function are guaranteed to be up-to-date. The output of the updater is shallowly merged with prevState.
/// This method can only be called in the constructor
105
104
[<Emit("this.state = $1")>]
106
-
member__.setInitState(value:'S):unit =jsNative
105
+
memberx.setInitState(value:'S):unit =x.state <- value
107
106
108
107
/// By default, when your component’s state or props change, your component will re-render. If your render() method depends on some other data, you can tell React that the component needs re-rendering by calling forceUpdate().
109
108
/// Calling forceUpdate() will cause render() to be called on the component, skipping shouldComponentUpdate(). This will trigger the normal lifecycle methods for child components, including the shouldComponentUpdate() method of each child. React will still only update the DOM if the markup changes.
110
109
/// Normally you should try to avoid all uses of forceUpdate() and only read from this.props and this.state in render().
/// Invoked immediately before mounting occurs. It is called before render(), therefore calling setState() synchronously in this method will not trigger an extra rendering. Generally, we recommend using the constructor() instead.
118
117
/// Avoid introducing any side-effects or subscriptions in this method. For those use cases, use componentDidMount() instead.
@@ -171,50 +170,6 @@ module React =
171
170
172
171
interface ReactElement
173
172
174
-
#else
175
-
and [<AbstractClass>]Component<'P,'S>(initProps:'P)=
176
-
member__.props:'P = initProps
177
-
178
-
member__.children:ReactElement array =[||]
179
-
180
-
member valstate:'S = Unchecked.defaultof<'S>with get, set
181
-
182
-
memberx.setState(value:'S):unit = x.state <- value
0 commit comments