Recursion on classes when a method is used as a prop (ie onClick)
See original GitHub issueI stumble upon on a recursion issue, The following:
class App extends Component {
onClick() {}
render() {
return <Box onClick={this.onClick} />;
}
}
compiles to
class App extends _mobxJsx.Component {
onClick() {}
render() {
return (0, _mobxJsx.createComponent)(Box, {
get onClick() {
return this.onClick
}
})
}
}
Demo: https://codesandbox.io/s/mobx-counter-context-bug-forked-wp9m9?file=/index.js
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
onClick change from class to function - Stack Overflow
props.onClick() everytime the component is rendered. The return value of this.props.onClick() would then be set as the onClick value.
Read more >this - JavaScript | MDN
When a function is used as a constructor (with the new keyword), its this is bound to the new object being constructed, no...
Read more >How to Use Recursion in React - freeCodeCamp
Recursion simply means calling the same function inside itself, or rendering a component inside the same component. What will happen is, the ......
Read more >Recursion and stack - The Modern JavaScript Tutorial
Recursion is a programming term that means calling a function from itself. Recursive functions can be used to solve tasks in elegant ways....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok happy to say fixed in babel-plugin-jsx-dom-expressions v0.20.8. Let me know if you have any more issues.
Ok this is next on my list assuming I can do it easily enough. I want to get this in for my next minor release of my libraries but I don’t want it to delay the next Solid release.