score:3
Accepted answer
are you just calling this.onprojectselect.bind(this);
or are you assigning it back go this.onprojectselect
? the bind
function returns a new function, so i would expect to see:
this.onprojectselect = this.onprojectselect.bind(this);
score:2
i think you could be missing the state initializing on the constructor, or maybe you are just making a mistake in the binding. i would do something like this:
export default class test extends component{
constructor(props) {
super(props)
this.state = {
project: ''
}
}
onprojectselect = (e) => {
this.setstate({
project: e.target.value
});
}
render(){
return (
<select2
data={basicstore.projectsselect2format}
onchange={this.onprojectselect}
options={{
placeholder: 'search project',
}}
/>
)
}
}
Source: stackoverflow.com
Related Query
- setState is not working inside event function
- React SetState not working till second render if HTML element updated inside a function
- setState not working inside onChange function
- setState not working inside a simple if condition of a function
- ReactJS Array.push function not working in setState
- How to not use setState inside render function in React
- Mouse scroll event Is not working for react select inside react scrollbar
- setState in reactjs inside success function not setting state
- setState inside constructor not working properly: ReactJS
- React firebase auth() setState not working inside then()
- React setState not working using event property
- React - onClick function not working inside a flexbox
- React Conditional Rendering of Component Inside Function Not Working
- Async function inside useMemo not working
- spread operator not working in nested setState within useEffect using .map() function
- react js setstate inside event inline function
- setState inside a useEffect not working in enzyme
- React setState function not reached thus not working
- setState not working inside axios fetch
- OnClick event not working in map function react
- Function inside of Redux middleware not working
- On Change event inside Typeahead is not working
- setState not working inside useEffect hook
- useState Hook not working inside event listener
- Hooks can only be called inside of the body of a function component. useState is not working
- returning component inside function not working
- reactjs - Function not working inside a map function
- React onclick setState not working with arrow function
- Function not working on onClick event in React.js
- How to use setState inside render function without onClick event
More Query from same tag
- react-testing-library validateDOMNesting Error
- React: How to get the ref height of an element coming from the children with dynamic height?
- React - TypeError: setActiveProject is not a function
- Using breakpoints on my navigation bar with MUI5
- Type checks not working in a create-react-app typescript project
- Nextjs - How to pass params to server router with Link
- How can I replace gsi with empty string('') from a string using JavaScript?
- Why does React say not to set 'selected' property on <option> elements?
- I want to add elements in array dynamically in following format
- React.render replace container instead of inserting into
- How can I correctly get this component to render?
- React.js How can I convert string base64 to normal image
- Storing JSX code for late rendering
- Immutable JS List size
- How can I set params from rails server on Transfer List?
- Is it possible pass a function to Chakra's isInvalid property?
- How to return values from a react component to the calling module?
- Clicked mouseover to apply style
- React and Material UI: How to include a space between Select and InputLabel?
- How to use scss without css modules in nextjs
- How to do multiple optional params with react-router?
- React App suddenly stopped working; TypeError: Cannot read properties of undefined (reading 'prototype')
- How to config webpack to load custom fonts into storybook?
- Select with React.JS - dynamically populated options
- Unable to render two-level deep nested object with map
- Is it possible to use Uppy with Drag and Drop using XHR Upload mode?
- Typescript Scroll window function type
- Adding element to Active NavLink React
- How to secure component/path behind authentication in react?
- React Initiating component re-render after onChange event received data from Paste (ctrl+v)