These are chat archives for ramda/ramda

13th
Jul 2017
Ryan Bas
@ryanbas21
Jul 13 2017 15:59
anyone know why using Ramda's map would cause my list to render differently than the native map in JSX?
Kurt Milam
@kurtmilam
Jul 13 2017 16:08
@ryanbas21 can you work up a quick example of how you're calling each?
Ryan Bas
@ryanbas21
Jul 13 2017 16:08
nevermind im special
Kurt Milam
@kurtmilam
Jul 13 2017 16:08
:thumbsup:
Ryan Bas
@ryanbas21
Jul 13 2017 16:08
just out of curiousity if i have R.map(callbackhere)(array) shouldn't that work?
technically since its curried?
Kurt Milam
@kurtmilam
Jul 13 2017 16:09
yes, that should work
Ryan Bas
@ryanbas21
Jul 13 2017 16:10
let me see what I had because it was mapping it, but wasn't applying the styles that it should have had
it was odd
Kurt Milam
@kurtmilam
Jul 13 2017 16:12
REPL
const incAll = map( inc )
incAll( [ 1, 2, 3, 4 ] )
// --> [ 2, 3, 4, 5 ]
Ryan Bas
@ryanbas21
Jul 13 2017 16:12
{
            (
              R.map(name =>
                <MenuItem key={name} style={{ paddingLeft: 10 }}>
                  <Avatar icon={<UserIcon />} style={{ margin: 5 }} />{name}
                </MenuItem>,
              ),
              Names
            )
          }
the trailing comma was the issue
Kurt Milam
@kurtmilam
Jul 13 2017 16:12
:thumbsup:
Ryan Bas
@ryanbas21
Jul 13 2017 16:12
not sure how Ramda handles that, because it still got mapped just didnt apply the callback
Kurt Milam
@kurtmilam
Jul 13 2017 16:14
According to the REPL, it ignores the trailing comma.
Michael Rosata
@mrosata
Jul 13 2017 16:14
@ryanbas21 your Names are capitalized, I wonder if JSX thinks it's a component
I know components can't be lowercased or they won't work, I don't know if that could effect your mapping in the JSX
Kurt Milam
@kurtmilam
Jul 13 2017 16:15
map( inc, )( [ 1, 2, 3, 4 ] )
// -> [ 2, 3, 4, 5 ]
Michael Rosata
@mrosata
Jul 13 2017 16:16
I personally have had an issue with Ramda map not working in JSX. I don't know what it is, or what caused it, but it happened, drove me nuts and I was able to fix whatever it by switching to Array.prototype.map. I don't think I was using React at the time, but it was JSX
Kurt Milam
@kurtmilam
Jul 13 2017 16:17
Interesting. I haven't run into any issues with R.map and JSX.
Ryan Bas
@ryanbas21
Jul 13 2017 16:21
Yeah, the Names capitilization although i understand not the right practice, isn't the issue. Oddly, the trailing comma just caused the callback to not be applied. Not sure otherwise though. It works now with Ramda just not currying which i didn't actually mean to do I just misread my mess of a code
its the reason i started to bring ramda in, clean some of my mess up :P
Michael Rosata
@mrosata
Jul 13 2017 16:22
@kurtmilam that's good to know. The project I'm on is React, and I will have an R.map in my JSX that works fine, but I'll end up thinking "uh-oh, I better switch that out just in case"... all because of that experience I had. It could have been attributed to the fact I was using JSX, Virtual-Dom and a bootleg Redux
Kurt Milam
@kurtmilam
Jul 13 2017 16:23
I'm working withJSX in calmm-js, which provides a lifted version of Ramda.map in its karet.util package, btw.
Michael Rosata
@mrosata
Jul 13 2017 16:24
@ryanbas21 must be the compiler/transpiler messes up with that comma dangle inside the JSX
@kurtmilam I wonder if my problem was just a compile problem too. Maybe I'll try to reproduce it later. I think I remember the exact project/file that it happened at
Kurt Milam
@kurtmilam
Jul 13 2017 16:26
@ryanbas21 your syntax is wrong there. The actual problem is that you're doing this:
( Ramda.map( inc ), [ 1, 2, 3, 4 ] )
// -> [ 1, 2, 3, 4 ]
Should be:
( Ramda.map( inc, [ 1, 2, 3, 4 ] ) )
// -> [ 2, 3, 4, 5 ]
The trailing comma wasn't the issue.
You never passed Names into the curried map function. A correct alternate syntax would be this:
( Ramda.map( inc )( [ 1, 2, 3, 4 ] ) )
// -> [ 2, 3, 4, 5 ]
@mrosata It would be interesting to hear what you find out.