@fto-consult/expo-ui 6.21.3 → 6.21.5

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 +13 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import { registerRootComponent } from "expo";
2
+ import { View } from "react-native";
2
3
  import App from "./src/App";
3
4
  import Provider from "$econtext/Provider";
4
- import APP from "$capp/instance";
5
5
  const REGISTER_EVENT = "REGISTER-APP-COMPONENT-ROOT";
6
6
  import {useState,useEffect} from "react";
7
- const appRegisteredRef = {current:false};
7
+ const appRegisteredRef = {current:null};
8
+ import APP from "$capp/instance";
9
+ import {isObj} from "$cutils";
10
+
8
11
 
9
12
  /****
10
13
  * les options sont de la forme :
@@ -24,10 +27,10 @@ const appRegisteredRef = {current:false};
24
27
  //!isWeb && registerRootComponent(x=>null);
25
28
 
26
29
  const MainAppEntry = function(mProps){
27
- const [props,setProps] = useState(null);
30
+ const [props,setProps] = useState(appRegisteredRef.current);
28
31
  const onRegisterProps = (props)=>{
29
- appRegisteredRef.current = true;
30
- console.log(props," is registered");
32
+ if(isObj(appRegisteredRef.current) || !isObj(props)) return;
33
+ appRegisteredRef.current = props;
31
34
  setProps({...props});
32
35
  }
33
36
  useEffect(()=>{
@@ -36,8 +39,9 @@ const MainAppEntry = function(mProps){
36
39
  APP.off(REGISTER_EVENT,onRegisterProps);
37
40
  }
38
41
  },[]);
39
- if(!props) {
40
- console.log(props," not registered",mProps);
42
+ props = isObj(props) ? props : appRegisteredRef.current;
43
+ if(!isObj(props)) {
44
+ console.log(props," not yet registered",mProps);
41
45
  return null;
42
46
  }
43
47
  const rProps = {...mProps,...props};
@@ -47,9 +51,8 @@ const MainAppEntry = function(mProps){
47
51
  };
48
52
 
49
53
  export default function registerApp (opts){
50
- if(appRegisteredRef.current) return false;
51
- console.log("will register event ",opts);
52
- return APP.trigger(REGISTER_EVENT,opts);
54
+ appRegisteredRef.current = opts;
55
+ APP.trigger(REGISTER_EVENT,opts);
53
56
  }
54
57
 
55
58
  registerRootComponent(MainAppEntry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.21.3",
3
+ "version": "6.21.5",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {