Skip to content

Commit

Permalink
Fix createElementKeyed_ to refer correct 'createElement' (#47)
Browse files Browse the repository at this point in the history
I might just be very confused here, I didn't try using
`createElementKeyed` myself, and none of examples are using it, so
it's just an educated guess (TODO: add example).

There are following foreign imports in `React.Basic`:

```haskell
foreign import createElement_ :: forall props. Fn2 (ReactComponent { | props }) { | props } JSX
foreign import createElementKeyed_ :: forall props. Fn2 (ReactComponent { | props }) { key :: String | props } JSX
```

They are pretty much the same, except that one allows to set the `key`
property. Implementations are defined as follows:

```haskell
exports.createElement_ = function(el, attrs) {
  return React.createElement.apply(
    null,
    [el, attrs].concat((attrs && attrs.children) || [])
  );
};

exports.createElementKeyed_ = React.createElement;
```

The `React.createElement` seems like a typo, as it won't even match a
type. It should be `exports.createElement_` instead.
  • Loading branch information
zudov authored and spicydonuts committed Jul 24, 2018
1 parent 8c34fe8 commit e16118d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/React/Basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ exports.createElement_ = function(el, attrs) {
);
};

exports.createElementKeyed_ = React.createElement;
exports.createElementKeyed_ = exports.createElement_;

exports.fragment = function(children) {
return React.createElement.apply(null, [Fragment, {}].concat(children));
Expand Down

0 comments on commit e16118d

Please sign in to comment.