Skip to content
Merged
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
11 changes: 11 additions & 0 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2078,6 +2078,17 @@ module Util =
| value -> Some(props, [ value ])
else
Some((key, value) :: props, children)
// When the string value exceeds ~100 chars, Fable wraps it in a Let binding.
// The Let body still contains the tuple with the prop key and a reference to the bound var;
// we use the bound value (letValue) as the actual prop value.
| Some(props, children),
MaybeCasted(Fable.Let(_, letValue, MaybeCasted(Fable.Value(Fable.NewTuple([ StringConst key; _ ], _), _)))) ->
if key = "children" then
match letValue with
| Replacements.Util.ArrayOrListLiteral(children, _) -> Some(props, children)
| _ -> Some(props, [ letValue ])
else
Some((key, letValue) :: props, children)
| Some _, e ->
addError com [] e.Range "Cannot detect JSX prop key at compile time"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,11 @@ let propsCanUseUnbox =
Html.div [
unbox<JSX_IReactProperty> ("id", "myid")
]

// Regression test for https://github.com/fable-compiler/Fable/issues/3839
// String values longer than ~100 chars were wrapped in a Let binding by Fable,
// causing transformJsxProps to fail with "Cannot detect JSX prop key at compile time".
let divWithLongClassName =
Html.div [
prop.className "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
]
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,5 @@ export function divWithConditionalWithoutElseBranchWorks(show) {
}

export const propsCanUseUnbox = <div id="myid" />;

export const divWithLongClassName = <div className="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" />;
Loading