@fto-consult/expo-ui 6.21.4 → 6.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +15 -18
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,10 +4,10 @@ import App from "./src/App";
4
4
  import Provider from "$econtext/Provider";
5
5
  const REGISTER_EVENT = "REGISTER-APP-COMPONENT-ROOT";
6
6
  import {useState,useEffect} from "react";
7
- const appRegisteredRef = {current:false};
8
- import {observable} from "$clib/observable";
9
- const context = {};
10
- observable(context);
7
+ const propsRef = {current:null};
8
+ import APP from "$capp/instance";
9
+ import {isObj} from "$cutils";
10
+
11
11
 
12
12
  /****
13
13
  * les options sont de la forme :
@@ -27,34 +27,31 @@ observable(context);
27
27
  //!isWeb && registerRootComponent(x=>null);
28
28
 
29
29
  const MainAppEntry = function(mProps){
30
- const [props,setProps] = useState(null);
30
+ const [props,setProps] = useState(propsRef.current);
31
31
  const onRegisterProps = (props)=>{
32
- if(appRegisteredRef.current) return;
33
- appRegisteredRef.current = true;
34
- console.log(props," is registered");
32
+ if(isObj(propsRef.current) || !isObj(props)) return;
33
+ propsRef.current = props;
35
34
  setProps({...props});
36
35
  }
37
36
  useEffect(()=>{
38
- console.log("binding event ",context);
39
- context.on(REGISTER_EVENT,onRegisterProps);
37
+ APP.on(REGISTER_EVENT,onRegisterProps);
40
38
  return ()=>{
41
- context.off(REGISTER_EVENT,onRegisterProps);
39
+ APP.off(REGISTER_EVENT,onRegisterProps);
42
40
  }
43
41
  },[]);
44
- if(!props) {
45
- console.log(props," not registered",mProps);
46
- return <View/>;
42
+ const cProps = isObj(props) ? props : propsRef.current;
43
+ if(!isObj(cProps)) {
44
+ return null;
47
45
  }
48
- const rProps = {...mProps,...props};
46
+ const rProps = {...mProps,...cProps};
49
47
  console.log(rProps," is props ready to render");
50
48
  const {onMount,onUnmount,onRender,render,swrConfig,init,...rest} = rProps;
51
49
  return <Provider {...props} {...rest} swrConfig={isObj(swrConfig) && swrConfig || {}} children={<App init={init} render={render} onMount={onMount} onUnmount={onUnmount} onRender={onRender}/>}/>
52
50
  };
53
51
 
54
52
  export default function registerApp (opts){
55
- if(appRegisteredRef.current) return false;
56
- console.log("will register event ",opts);
57
- return context.trigger(REGISTER_EVENT,opts);
53
+ propsRef.current = opts;
54
+ APP.trigger(REGISTER_EVENT,opts);
58
55
  }
59
56
 
60
57
  registerRootComponent(MainAppEntry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.21.4",
3
+ "version": "6.21.6",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {