With pure functions in React it's easy to make any variable you create reusable by any other nested functions:
const myComponent = props => {
const {something} = props.nested;
const nestedFunction = () => {
if (something === "value") return true
}
const otherNestedFunction = () => {
console.log(otherNestedFunction)
}
return (
// markup
)
}
Can you do something similar with a React class? At the moment Im having to repeat creating the variable.
class myComponent extends React.Component() {
nestedFunction() {
const {something} = props.nested;
if (something === "value") return true
}
otherNestedFunction() {
const {something} = props.nested;
console.log(otherNestedFunction)
}
render(){
return (
// markup
)
}
}