score:3
Accepted answer
Your action is asynchronous. It means that 'then' function fires only when getDownloadURL() is finished. But console.log fires immidiately, when the content is null yet. So if you want to do something with content, you should do it inside 'then' callback:
let content = null;
storage.ref().child(snapshot.val().content).getDownloadURL()
.then(url => {
content = url;
console.log('content', content);
} );
Source: stackoverflow.com
Related Query
- React Variable value is not changing
- React - value of a variable not changing properly
- useState set method not changing the value - React
- React Component Not Updating After Changing A Value
- React select onChange not changing selected value
- React Hooks: state variable having wrong value in event handlers, not able to type in input
- React - changing state not updating elements rendered from variable
- react - copy state to local variable without changing its value
- React not changing local state dropdown value
- Why is the value of my variable not showing in the render for my react component?
- React input value is not getting updated although value next to it with same variable is
- React Context is not working as expected: Unable to change the value of shared variable
- Passing a function as a callback to a React state created with hooks did not reflect new value of variable
- Value of Select Tag from state dom is not changing in react
- Reactive variable value change not updating React component
- React Hook Form value is not changing when swapping or Deleting Groups
- onChange is not working in react functional component while changing the value through state update
- React component not sending variable value with onChange event
- React rendering problem in input box after fetching data in useEffect(). the state changed but textbox value not changing
- variable value not changing inside axios then method
- React component not re-rendering and showing CSS change upon value changing
- PHP Session ID / Session variable value changing on every request from react axios / ajax call
- React - useState not setting initial value
- React changing props on grandchildren: object is not extensible / tree traversing react children
- Dynamic Opacity not changing when component rerenders in react native
- TypeError: Class extends value undefined is not a constructor or null in react js
- React hooks value is not accessible in event listener function
- React useState does not seem to accept a default value here?
- React + Redux: "<Provider> does not support changing `store` on the fly"
- React hooks state variable not updating after rerender
More Query from same tag
- React Router dynamic routing based on JS Array
- Testing wrapper.props shallow render is undefined
- TypeError: undefined is not a function with React and Express
- How manage state of unknown number of text areas?
- Jest / Enzyme - mock async function in lifecycle method
- Access React context in an API service
- Could not find a declaration file for module, @types/...@latest' is not in the npm registry
- Tailwind CSS unnecessary whitespace
- How to use react-s3-uploader with reactjs?
- Refactor React code, to use Redux state from a Firebase RT database & Redux Hooks
- How can I change MUI v5 Button to lighten on hover instead of darken using theme?
- bootstrap range slider in ReactJS in jsx
- Send value to child component in react
- Cannot read property 'animateMarkerToCoordinate' of undefined
- React Query w/NextJS - I'm noticing that, once my page has loaded, the query does not execute until I have clicked within the browser's viewport
- REACT - auto submit form after files uploaded to state the contains array
- Using react-multi-carousel but unable to use custom dots
- How to clear your store
- Having trouble using Firebase storage + useEffect hook + useState hook to render images
- Chained Fetch Promises (JSON, React, Webpack, NodeJS)
- React: can you use setState with existing state object?
- Passing {ClassName} vs passing {<ClassName>} as react component porps. What is the difference?
- How Do you display data from an api in React?
- React - Change state in child component from another child component
- Why all datepicker values become null when I change one of this?
- react js hooks useEffect infinite loop
- ReactQuill loses focus
- React router functional component redirect on event
- Not able to change svg elements color by looping
- How to get the InputNumber name in antdesign for react?