Skip to content

Commit

Permalink
Fixed small state and props bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TCern committed Feb 10, 2020
1 parent 847e272 commit 96c3cc1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/StateAndPropsToValues.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
function ParseAndReplace(object: object, stateAndProps: object): object {
Object.keys(object).forEach(key => {
if (typeof object[key] === "string") {
if (/\$/g.test(object[key])) {
if (/\$/g.test(object[key]) && object["type"] !== "static") {
const parts = object[key].split(".");
if (parts[0] === "$props" || parts[0] === "$prop") {
object[key] =
stateAndProps["propDefinitions"][parts[1]]?.defaultValue ?? "";
object[key] = stateAndProps["propDefinitions"]
? stateAndProps["propDefinitions"][parts[1]]?.defaultValue ?? ""
: "";
} else if (parts[0] === "$state") {
object[key] =
stateAndProps["stateDefinitions"][parts[1]]?.defaultValue ?? "";
object[key] = stateAndProps["stateDefinitions"]
? stateAndProps["stateDefinitions"][parts[1]]?.defaultValue ?? ""
: "";
}
}
}
Expand Down

0 comments on commit 96c3cc1

Please sign in to comment.