I am having trouble figuring out how to correctly create a class field based on a property.
class Example extends Component {
example_titles = props.titles;
// ...
}
which results in
Line 7: 'props' is not defined no-undef
I call this class in another file that works 100% correctly unless I add this tag with the following call <Example titles={["titles"]} />
I am using the stage 2 in Babel to eliminate constructors. I am aware of how to do this with constructors, but am struggling to understand this without them.
You can access the props in class properties with
this.props
.