Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,23 @@ module.exports = function (_ref) {
var componentAttrs = {};
var internalInlineStyleAttrs = {};
var indexToBeRemoved = [];
attrs.map(function (attr, ind) {
if (attr.type !== "JSXSpreadAttribute" && ["colorScheme", "variant", "size"].includes(attr.name.name)) {
attrs.forEach(function (attr, ind) {
if (attr.type === "JSXSpreadAttribute" || !attr.value) {

@antoinerousseau antoinerousseau Jan 12, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because attr.value is sometimes null, leading to these errors:

TypeError: Cannot read properties of null (reading 'type')
    at node_modules/@native-base/babel-plugin/lib/index.js:207:138

return;
}

var isNBattr = ["colorScheme", "variant", "size"].includes(attr.name.name)

if (isNBattr) {
componentAttrs[attr.name.name] = attr.value.value;
}

if (attr.type !== "JSXSpreadAttribute" && !["colorScheme", "variant", "size"].includes(attr.name.name) && attr.value.type === "StringLiteral") {
if (!isNBattr && attr.value.type === "StringLiteral") {
internalInlineStyleAttrs[attr.name.name] = attr.value.value;
indexToBeRemoved.push(ind);
}

if (attr.type !== "JSXSpreadAttribute" && !["colorScheme", "variant", "size"].includes(attr.name.name) && attr.value.type === "JSXExpressionContainer" && attr.value.expression.type === "NumericLiteral") {
if (!isNBattr && attr.value.type === "JSXExpressionContainer" && attr.value.expression.type === "NumericLiteral") {
internalInlineStyleAttrs[attr.name.name] = attr.value.expression.value;
indexToBeRemoved.push(ind);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@native-base/babel-plugin",
"version": "1.0.13",
"version": "1.0.14",
"description": "A babel plugin to add Build time theme resolution for Nativebase",
"main": "lib/index.js",
"scripts": {
Expand Down