I have a parent component with a state which carries a theme string. (It's just for testing purposes at the moment so don't think too far into the practicality of it please :) ! )
Basically, this is the layout thus far.
Parent Component carries state of Theme.
Parent passes down current state to child component as "theme" prop using code "theme={this.state.theme}".
Trying to style child element inline with
style=
Getting the error: TypeError: Cannot read property 'props' of undefined.
I know this is because of how "this" is bound. However, what is the best approach for this?
I want the child element to match the state of the parent component but I need "this" bound correctly.
https://stackoverflow.com/questions/65444651/passing-state-down-into-a-prop-to-child-component-accessing-it-inline-with-th December 25, 2020 at 10:04AM
没有评论:
发表评论