@fto-consult/expo-ui 6.21.0 → 6.21.2

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 +12 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { registerRootComponent } from "expo";
2
- import {Platform,AppRegistry } from 'react-native';
3
2
  import App from "./src/App";
4
3
  import Provider from "$econtext/Provider";
5
4
  import APP from "$capp/instance";
6
5
  const REGISTER_EVENT = "REGISTER-APP-COMPONENT-ROOT";
7
6
  import {useState,useEffect} from "react";
7
+ const hasAPPRegistered = {current:false};
8
8
 
9
9
  /****
10
10
  * les options sont de la forme :
@@ -24,8 +24,9 @@ import {useState,useEffect} from "react";
24
24
  //!isWeb && registerRootComponent(x=>null);
25
25
 
26
26
  const MainAppEntry = function(mProps){
27
- const [props,setProps] = useState({});
27
+ const [props,setProps] = useState(null);
28
28
  const onRegisterProps = (props)=>{
29
+ hasAPPRegistered.current = true;
29
30
  console.log(props," is registered");
30
31
  setProps({...props});
31
32
  }
@@ -34,12 +35,19 @@ const MainAppEntry = function(mProps){
34
35
  return ()=>{
35
36
  APP.off(REGISTER_EVENT,onRegisterProps);
36
37
  }
37
- },[])
38
- const {onMount,onUnmount,onRender,render,swrConfig,init,...rest} = {...mProps,...props};
38
+ },[]);
39
+ if(!props) {
40
+ console.log(props," not registered",mProps);
41
+ return null;
42
+ }
43
+ const rProps = {...mProps,...props};
44
+ console.log(rProps," is props ready to render");
45
+ const {onMount,onUnmount,onRender,render,swrConfig,init,...rest} = rProps;
39
46
  return <Provider {...props} {...rest} swrConfig={isObj(swrConfig) && swrConfig || {}} children={<App init={init} render={render} onMount={onMount} onUnmount={onUnmount} onRender={onRender}/>}/>
40
47
  };
41
48
 
42
49
  export default function registerApp (opts){
50
+ if(hasAPPRegistered.current) return false;
43
51
  return APP.trigger(REGISTER_EVENT,opts);
44
52
  }
45
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.21.0",
3
+ "version": "6.21.2",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {