React Context: TypeError: render is not a function

前端 未结 1 1052
渐次进展
渐次进展 2021-01-01 14:11

I\'m trying to use React Context to pass a function to a nested child component, which effectively allows the child to update the parents state when pressed.

The pro

1条回答
  •  独厮守ぢ
    2021-01-01 14:44

    As the error states, should have the only child, and it should be a function. The error appears when it has multiple children, including text nodes.

    ; after embedded expression causes the problem. It's not a part of an expression, and making it a part of it would result in syntax error.

    It should be:

    
        {({ handleChange }) => (
            
                
                { props.var_name }
                { props.price }
                { props.sku }
            
        )}
    
    

    0 讨论(0)
提交回复
热议问题