-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-Rendering the code and creating multiple nested span when there is an action in the page #22
Comments
Can you give a code sample to replicate the issue? |
If you are using Highlight inside of an iterator such as map or a for, be sure to set the key with some identifier. Or if you know it will always be different, set the key with const rows = _.map(data, (val, key) => {
return (
<tr key={`logitem-${key}-${Date.now()}`}>
<td>{key}</td>
<td><Highlight className="xml">{val}</Highlight></td>
</tr>
);
});
return (
<table className="log-item table table-bordered">
<tbody>{rows}</tbody>
</table>
); |
Here is an example demonstrating the issue
When the content dynamically changes on each update, there is no problem. But if the I solve this by making sure only to re-render a component when the content actually changes. But react-highlight should not behave this way. I suppose it is a consequence of altering the DOM elements rendered by React. My guess is that even if React determines that nothing changes and there is no reason to manipulate a given DOM element, react-highlight will grab it and wrap it in a |
Had the same issue, I fixed it by making sure the component doesn't get re-rendered. But I also think |
@scragg0x |
Having the same issue unfortunately. @troelsim or @juancabrera, by any chance can you please post here what adjustments you made to ensure that |
Update here, Fix (or should I say "Hack") below: I followed @scragg0x recommendation and essentially included a For example:
With that said, I definitely agree that |
Another way to fix this is to return the const HighlightStable = React.memo(props => <Highlight {...props}></Highlight>); |
Re-Rendering the code and creating multiple nested span when there is an action in the page
for ex: if there is an button click and the block getting re-rendered and adding many nested span for the existing span elements
The text was updated successfully, but these errors were encountered: