Giter Club home page Giter Club logo

Comments (7)

edemaine avatar edemaine commented on August 20, 2024 1

The current behavior is particularly surprising when style is set to something other than an object literal:

<div style={/* @once */ props.style} />

Currently /* @once */ is ignored in this case. Playground

In any case, I've added some documentation about the current behavior so this is less surprising.

from dom-expressions.

ryansolid avatar ryansolid commented on August 20, 2024

Yeah style and classList are special in that they analyze on a per object expression level. So in this case put the once in front of each property.

<div style={ { width: /* @once */props.width, height: /* @once */props.height }} />

I realize there is nothing stopping us from oncing the whole object as well.

from dom-expressions.

titoBouzout avatar titoBouzout commented on August 20, 2024

I was just looking how to fix this, the logic seems to be here https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions/src/shared/utils.js#L87-L94
Im staring at this not knowing what to do with that information

from dom-expressions.

titoBouzout avatar titoBouzout commented on August 20, 2024

#258

from dom-expressions.

ryansolid avatar ryansolid commented on August 20, 2024

Yeah I have to admit when I added these features they were compiler only originally. There has been talk about just deprecating @once all together. It's nice to have the escape hatch. But it is also so specific. And actually doesn't guarantee once, just removes the specific tracking scope.

from dom-expressions.

titoBouzout avatar titoBouzout commented on August 20, 2024

I heard the expectation is to use a memo instead, is there other approach? Looks to me a bit of a waste, as there's going to be an effect created that is not going to be used, code would be bigger.

For the case in place, can you consider merging it regardless of the future of this feature, it makes it work closer to the intention and of what's expected.

from dom-expressions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.