score:0
if i correctly understand your problem. you need set default state for avoid null data
if you use class component in constructor of class you should set default value of state
class somecomponent extends react.component {
constructor(props) {
super(props);
this.state = {
somedata: []
};
}
}
if you use functional component you should use react hooks
const somecomponent = () => {
const [items, setitems] = usestate([]); // default value empty array
};
score:0
open your model based on condition like -
<div classname="template-profile">
<image
url={this.state.selectedimages.profilepicture}
mode={"profile"}
/>
<h6>hello i'm</h6>
<h1 classname="template-profile-name">
nabnit jha
</h1>
<h6>
{this.state.aboutmetext} // here state value display successfully
</h6>
<div classname="template-self-info">
{modelstatus&&<modals modalbody={this.state.aboutmetext} modalheading="about me"></modals>}
//here state value became null
</div>
</div>
function to make it true
function clickhandle
clickhandle=()=>{
this.setstate({modelstatus:true})
}
you use your function based on your requirement.
Source: stackoverflow.com
Related Query
- React state value became null when it pass to model
- pass boolean state value from parent class to child class when a button is clicked in the parent class in react js so that i can load quizes with bool
- React + Redux - Input onChange is very slow when typing in when the input have a value from the state
- Can not pass state with react router dom v6 beta, state is null
- React component rendering even when there is no change in the state value
- Set value of prop in child component and pass value back to state of app.js, react
- How to update specific value when the state is an array of objects - React
- How to pass one state value to another state on initialization in react js
- How to pass state value to a callback function using React Hooks
- Error coming when using the state value in react using typescript
- Passing a state or prop to pass a value to child component in react
- React print this.props only when value is not null
- React Recoil selector not triggering its get when the atom state updates to a previous value
- Unable to pass state value through react jsx. Getting error - Unexpected token : 'this'
- How to correctly type a null value in typescript react app, retrieved from an JSON object (api call) when using Object.entries to retrieve the value?
- rule validation not triggered on input field when value is changed from React state
- Input element's value in react component is not getting re-rendered when the state changes
- Why won't react modal input value populate when state is updated?
- How to pass state from class components to global state when using react hooks for global state management
- How to render component conditionally when leaf value of global state changes using react hooks
- pass the value of a checkbox to a state in React Js
- React router not working as expected when pass state to history.push
- How to dynamically update values in Shopping Cart when one item value is changing in React JS using state in map function?
- React Native TextInput have a Default Value How can we update/pass DefualtValue as a Text entry when state change (onchangetext)
- How to disable a button when the state or the input value gets changed in React JS?
- Value of state within React context not updating when used in another component
- React state shows null when calling from an onClick handler on a button through a dynamic generated component
- In react on first time data is getting fetched, when user move to chat with one another user, state value is not getting change
- Pass Redux selector value to react state without rerendering in useEffect
- React increment state value when radio button is clicked
More Query from same tag
- How to call an Async function in Non-Async function
- Redux Saga stopped by LOCATION_CHANGE too early
- Cannot read property 'setState' of undefined, inside Object.keys, react
- React state is undefined after checking for undefined
- How to test a REDUX action containg a time reference
- react fire multiple function in an event
- How can I close my hamburger menu when clicking on a link using React JS? (using ReactJS hooks)
- Unable to change decimal value in MUI v5 TextField
- Best option for continuously refreshing an HTML table (SPA)
- Posting data to Firebase (React)
- npm start not running in docker
- React Unknown Prop 'onSearch'
- Make Blacklist JWT tokens for spring boot
- Inconsistent focus() with React in Safari/Chrome/Firefox
- javascript csv header for all nested objects
- How can I extract a nested array of objects and put them in the core array?
- ReactJS with wowJS not working
- How can I import javascript min file in my component?
- Error: Type 'void' is not assignable to type 'ReactNode'
- Simulate "shift" pressing key on checkbox to select multiple rows
- managing array prop in react
- React Native - Navigate after an async action
- React Native: I press text input and keyboard is appears and is automatically dismissed once when using Keyboard.addListener
- I can't get cards displayed horizontally using React bootstrapping
- Using use-sound in React and Gatsby.js - How to stop audio playing on route change?
- Property 'accessToken' does not exist on type 'User' && firebase is not defined
- Change object key using Object.keys ES6
- Multi-select from bootstrap form - React Hooks
- Styling material ui table cells according to their values
- React Router v4 - Error: React.Children.only expected to receive a single React element child