3 ms·
So React added isReactComponent to Component class but the author doesn't explain why they couldn't just check for render() method. It works in this React-like
by petilon 8y ago
So React added isReactComponent to Component class but the author doesn't explain why they couldn't just check for render() method. It works in this React-like library:
https://github.com/wisercoder/uibuilder/blob/master/UIBuilder/UIBuilder.ts#L130 https://github.com/wisercoder/uibuilder/blob/master/UIBuilde...
- acemarke 8y agoSomeone else asked that same question on Reddit [0], and Dan pointed out the paragraph in the post that answers it : > One other possible heuristic could be to check for presence of a render method on the prototype. However, at the time it wasn’t clear how the component API would evolve. Every check has a cost so we wouldn’t want to add more than one. This would also not work if render was defined as an instance method, such as with the class property syntax. [0] https://www.reddit.com/r/reactjs/comments/a2j6xk/how_does_react_tell_a_class_from_a_function/eayzfhx/ https://www.reddit.com/r/reactjs/comments/a2j6xk/how_does_re...
- deleted 8y ago[deleted]