score:1
Accepted answer
because you use nested anonymous functions, the internal function scope of this
is different.
you can bind this
, or assign this
to another variable in upper function
(item) => {
const self = this;
return (h) => (
<button onclick={ () => {console.log(self)} }>
<span class="uk-margin-small-left" uk-icon="icon: file-edit"></span>
edit
</button>
);
}
Source: stackoverflow.com
Related Query
- Can't access Vue instance inside return jsx
- Access props inside quotes in React JSX
- Unable to access React instance (this) inside event handler
- Redux Form: Getting Access to Field Components meta.touched property inside JSX Form
- jsx console log inside map inside return statement
- Not able to see anything written inside the return component in JSX
- Cant access to method and property of an array inside React useEffect
- How to access dom element that is not inside JSX in React?
- Cannot access array inside of map function to return props to different component
- Cant access state inside reducer
- Why the onClick function works inside the jsx and don't work outside the return statement
- JSX syntax inside the return function of a component causing a blank white screen on the browser
- Could'nt return maped item inside jsx component
- Cannot return a jsx inside a map function
- Access child function from parent using refs when the child is a function component and the parent does not return JSX
- React, Express - GET data from database return array of objects, but I cant access to any object in array
- Return an object inside useEffect() and access it outside in React (after having assigned a state)
- Error in function call from inside return along with jsx
- Loop inside React JSX
- Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode
- How can I return multiple lines JSX in another return statement in React?
- How to access state inside Redux reducer?
- Component cannot be used as a JSX component. Its return type 'Element[]' is not a valid JSX element
- is there any way to access the parent component instance in React?
- Return multiple elements inside React.render()
- How to loop over a number in React inside JSX
- Adding a new line in a JSX string inside a paragraph - React
- Why can't I have a JSX comment inside an element tag?
- VSCode user snippet doesn't works inside jsx
- Cannot access State inside Function
More Query from same tag
- How to show/hide div in React?
- Two routes with different query strings for the same component
- Flatlist scrollToIndex with Hooks useRef
- react-hook-form - empty input field after each submit
- How to empty input values and reset state in ReactJS hooks
- Correctly dispatching logout action redux-saga
- No 'Access-Control-Allow-Origin' header is present on the requested resource using AWS API Gateway with AWS Lambda
- Property 'map' does not exist on type 'List'
- How to print out an array of user inputs in ReactJs
- How to update a state variable in an array in React?
- onclick event on multiple causes to trigger always the first div-JS/REACTJS
- Update useContext every second
- ReactJS Form Submission
- redux-toolkit giving me that circular dependency issue
- Typescript error with NextJS and Context API
- How to use input together with redux?
- Scope of This in a React/ES6 Class
- Access location property in App component
- How to combine HighStock stock-chart and HighCharts bubble-chart in React JS?
- TypeError: Cannot read properties of undefined (reading 'img') React
- Update Sass (SCSS) variables programmatically from React
- How to 'useState' correctly in Formik 'onSubmit' function?
- change styles dynamically with react memo
- Display Data Got From JSON In Reactjs In Table
- React router change url change navlinks icon
- Bottom Fixed div getting pushed up with android keyboard
- React app freezing when setInterval is called
- Using Mocha to test file download using file-saver in a react project, gives "ReferenceError: HTMLAnchorElement is not defined" error
- How to send multiple images form react
- ReferenceError: Cannot access 'UserContext' before initialization - React