These are chat archives for jdubray/sam

2nd
Oct 2017
Janne Siera
@jannesiera
Oct 02 2017 14:21

@jdubray very approachable article. I like that it has a lot of small code samples and I believe it gets your points accross (whether the reader agrees with them or not). If I can make one suggestion, it would be to add <div> tags to your 'stateless component' example. You don't have them in your ES6 example while you DO have them in your React example. Which could come accross as disingenuous.

I also had a question. How do you pass intents to your components? Especially when you have nested components?

Jean-Jacques Dubray
@jdubray
Oct 02 2017 14:26
@jannesiera thank you for the feedback. I was wondering the same thing, since you may think that's not HTML, but at the same time, I wanted to show, as you point out, that you don't have to do what React mandates (all JSX snippets must be enclosed within a single tag). Maybe I'll add some text explaining that point. The ToDo example has HTML snippets.
Passing intent is a breeze! It would look like this:
let TodoList = function({items, onclick}) {
    return `
       <ul>
         ${items.map(item => `<li key="${item.id}" ${(onclick) ? `onclick="${onclick}()"` : ``}>${item.text}</li>`)}
      </ul>`
}
The parent can just pass a string and voila! The parent can be owner of the intent or not!
Isn't that pretty?
I may have created the smallest working Front-End library!
Jean-Jacques Dubray
@jdubray
Oct 02 2017 14:32
Please note that I can also pass paramters such as:
${(onclick) ? `onclick="${onclick}(${item.id}, ${item.text})"` : ``}
Janne Siera
@jannesiera
Oct 02 2017 14:38
@jdubray alright, thanks!
Fred Daoud
@foxdonut
Oct 02 2017 15:07

@jdubray just FYI

what React mandates (all JSX snippets must be enclosed within a single tag)

This is no longer a restriction in React 16.
Jean-Jacques Dubray
@jdubray
Oct 02 2017 15:09
I see, thank you. Not sure why they didn't update the samples.