| @@ -32,14 +32,13 @@ const DemoComponent1 = (props) => { | |||
| const isLogged = useSelector(state => state.isLogged); | |||
| const dispach = useDispatch(); | |||
| const { store } = useContext(ReactReduxContext); | |||
| const [userName, setUserName] = useState(); | |||
| useEffect(()=>{ | |||
| if(user){ | |||
| useEffect(() => { | |||
| if (user) { | |||
| setUserName(user); | |||
| } | |||
| },[user]) | |||
| }, [user]) | |||
| const handleSubmit = (event) => { | |||
| event.preventDefault(); | |||
| @@ -85,13 +84,13 @@ const DemoComponent1 = (props) => { | |||
| <label> | |||
| Name: | |||
| <input ref={textInput} type="text" onChange={null} /> | |||
| <p>{userName}</p> | |||
| </label> | |||
| <input type="submit" value="Submit" /> | |||
| <button style={{backgroundColor: isLogged ? "green" : "white"}} onClick={() => dispach(setLogged())}>Log in</button> | |||
| <button style={{backgroundColor: isLogged ? "white" : "red"}} onClick={() => dispach(setNotLogged())}>Log out</button> | |||
| <button onClick={() => GetStore()}>Log Store</button> | |||
| </form> | |||
| <button style={{ backgroundColor: isLogged ? "green" : "white" }} onClick={() => dispach(setLogged())}>Log in</button> | |||
| <button style={{ backgroundColor: isLogged ? "white" : "red" }} onClick={() => dispach(setNotLogged())}>Log out</button> | |||
| <label style={{ marginLeft: "5px" }}> User: {user}</label> | |||
| {/* <button onClick={() => GetStore()}>Log Store</button> */} | |||
| </div> | |||
| <div style={{ backgroundColor: 'white', minHeight: '100%', width: '50%', padding: '5px' }}> | |||
| <p style={{ paddingTop: "5px", fontWeight: "bold" }}>Select Elements to hide</p> | |||