When I use the reactn library ( that manage and facilitate hooks) to get my initial global state that I assigned with setGlobal its not setting anything. When I try to get It says undefined.
I have used this library before and it usually is just a matter of importing like : import React from "reactn"; import { setGlobal } from "reactn";
And then just set the globals.
import React from "reactn";
import { setGlobal } from "reactn";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
ReactDOM.render(<App />, document.getElementById("root"));
setGlobal({
test: "test",
something: { attr1: "something", attr2: "something", attr3: "something"}
});
serviceWorker.register();
import React, { useEffect, useGlobal } from "reactn";
export default function Engine(props){
const [something, setSomething] = useGlobal("something");
const [test] = useGlobal("test");
console.log(something, test)
useEffect( ()=>{
console.log(something, test)
} );
return(
<div></div>);
}
I expected the values that I'm supposed to get instead of undefined undefined