Skip to content

Commit 11514d6

Browse files
CATISNOTSODIUMCATISNOTSODIUM
authored andcommitted
fix(tracer): rendering issue with literal AST
1 parent bac739b commit 11514d6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/commons/sideContent/content/SideContentSubstVisualizer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ type SubstVisualizerPropsAST = {
9494
};
9595

9696
const SideContentSubstVisualizer: React.FC<SubstVisualizerPropsAST> = props => {
97-
console.log(props);
9897
const [stepValue, setStepValue] = useState(1);
9998
const lastStepValue = props.content.length;
10099
const hasRunCode = lastStepValue !== 0;
@@ -245,12 +244,15 @@ function composeStyleWrapper(
245244
*/
246245
function renderNode(currentNode: StepperBaseNode, renderContext: RenderContext): React.ReactNode {
247246
const styleWrapper = renderContext.styleWrapper;
248-
249247
const renderers = {
250248
Literal(node: StepperLiteral) {
251-
return (
252-
<span className="stepper-literal">{node.raw ? node.raw : JSON.stringify(node.value)}</span>
253-
);
249+
const stringifyLiteralValue = (value: any) =>
250+
typeof value === 'string'
251+
? '"' + value + '"'
252+
: value !== null
253+
? value.toString()
254+
: 'null';
255+
return <span className="stepper-literal">{node.raw ? node.raw : stringifyLiteralValue(node.value)}</span>;
254256
},
255257
Identifier(node: StepperIdentifier) {
256258
return <span>{node.name}</span>;

0 commit comments

Comments
 (0)