Coder Social home page Coder Social logo

Comments (5)

emmagoldblum avatar emmagoldblum commented on May 13, 2024 1

Hi,

My guess is that the function that calculate the position of ports is not called with custom styled.div, the name of the function is onPortPositionChange, and it doesn't appear in the props passed to the custom node component (in the otherProps). I made a little test where i am passing NodeDefault as a customNode, and I had the same bug, and it appears that NodeDefault doesnt have this function as props either. The NodeWrapper has it.

Do you think it could be that ?

from react-flow-chart.

mgcostaParedes avatar mgcostaParedes commented on May 13, 2024

Hello, yes, that should be the problem, someone already implemented some other way to fix that issue?

Thank you.

from react-flow-chart.

emmagoldblum avatar emmagoldblum commented on May 13, 2024

Hi again,
thanks to the help of another user, i think it might be a problem of ref.

This code is actually working for me :

export const CustomNode = forwardRef((props, ref) => <Node innerRef={ref} {...props} />)

const Node = ({ innerRef, isSelected, node, className, style, ...rest }) => (

)

Do you think passing the props innerRef as ref into the styledComponent might fix it ?

from react-flow-chart.

krashdifferent avatar krashdifferent commented on May 13, 2024

NodeWrapper passes the callback to the PortWrapper which calculates position on component update life cycle. I don't have this issue but am not sure exactly what you are doing differently to cause it. I hav eonly used and looked at 0.7 so I don't know what was changed on that update. I use my own container to manage the state more directly but should still be using the default actions to manage position updates. I'm assuming you are using FlowChartWithState? If you are using the stateless FlowChart, you would need to manually add the port positions to the chart object. Are you using custom components for Port or Ports?

from react-flow-chart.

timbrunette avatar timbrunette commented on May 13, 2024

I had the same issue, have taken the storybook example NodeCustom and modified it to the following:

const NodeCustom = forwardRef(({ node, children, ...otherProps }, ref) => {
  if (node.type === 'output-only') {
    return (
      <DarkBox ref={ref} {...otherProps}>
        {children}
      </DarkBox>
    );
  } else {
    return (
      <Circle ref={ref} {...otherProps}>
        {children}
      </Circle>
    );
  }
});

This solved the problem for me.

from react-flow-chart.

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.