jsx-to-string icon indicating copy to clipboard operation
jsx-to-string copied to clipboard

Attaching or binding a function on the "onClick" event has an error.

Open belmer opened this issue 8 years ago • 4 comments

I just followed the example and somehow created my own based on the example. This is how the parsed look like https://screencast.com/t/pCDuO0lb

Basically, onclick-"{function}..." is not gonna work.

belmer avatar Feb 15 '17 12:02 belmer

can you add here the call you are making to the jsx-to-string?

alansouzati avatar Feb 15 '17 16:02 alansouzati

@alansouzati

It is something like this jsxToString(<div> <input name="selected-style" type="checkbox" onClick={self.checkBoxHandler}/></div>)

and checkBoxHandler is just doing a console log.

checkBoxHandler() { console.log('@checkBoxHandler') }

belmer avatar Feb 16 '17 05:02 belmer

if you are not sending any parameters I would expect all functions to be onClick={...}, this is the default behavior.

You can try to tinker with useFunctionCode and functionNameOnly to get a different results.

I'm not sure where this onclick-"{function}..." is coming from.

By default I set {...} because it is pretty hard (if not impossible) to grab the function code, specially for binded functions.

alansouzati avatar Feb 17 '17 16:02 alansouzati

hey @belmer any update here?

alansouzati avatar Mar 07 '17 20:03 alansouzati