Want to pass an external method to a stateless functional component in React You need to pass in a function. You are actually executing the FlowRouter.go function by calling FlowRouter.go(“Register”).
1 2 3 4 5 6 7 8 | const ParentComponent = () => { // define text and styles here return ( <div> <Button text={text} style={styles} action={() => FlowRouter.go("Register")}/> </div> ); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.