refactor: Clean up a bit post #1155 & #1150#1157
Conversation
| "rules": { | ||
| "react/sort-comp": 0, | ||
| "react/no-danger": 0, | ||
| "react/jsx-no-bind": 0, |
There was a problem hiding this comment.
Is anyone against this getting silence? Granted, many of them are my fault, but we have dozens of warnings that I don't think are important to anyone these days?
| // TODO: CodeMirror v5 cannot load in Node, and loading only the runner | ||
| // causes some bad jumping/pop-in. For the moment, this is the best option | ||
| typeof window === 'undefined' | ||
| ? null | ||
| : <Splitter |
There was a problem hiding this comment.
There is already a if (typeof window === 'undefined') return null above, this does nothing. Was a relic from when I was trying to see if I could prerender the content portion of the tutorial but skip the editor & runner (I could not, at least not well enough to ship).
Evidently I forgot to clean it up.
| function initialCode(query) { | ||
| let code, slug; | ||
| async function getInitialCode(query) { | ||
| const { route } = useLocation(); |
There was a problem hiding this comment.
Admittedly this block was a bit of a mess that I should have given a better look over.
Fixes an issue with ?code being cleared from the URL on mount (though the code would still populate correctly) and drops history.replaceState in a few places in favor of route().
This still isn't great, preact-iso has a rather fundamental issue at the moment (IMO) in that it updates the location context as soon as it matches a route. This leads to really awful control flow w/ suspense as you cannot rely on the content being updated alongside a path change -- content will update in a subsequent render. It's workable, just... fiddly. I was trying to avoid some of the woes by using history.replaceState but this refactor should work well while getting us in a position to take advantage of a fix to iso in the future (though I think it'll need a major).
| const { route } = useLocation(); | ||
| const { query } = useRoute(); | ||
| const [editorCode, setEditorCode] = useStoredValue('preact-www-repl-code', code); | ||
| const [exampleSlug, setExampleSlug] = useState(slug || ''); |
There was a problem hiding this comment.
Most of the slug changes here are, again, due to me trying to run around iso when I wrote this due to the awkward update order.
6a5b3b1 to
eb67ebd
Compare
| footer { | ||
| display: none !important; | ||
| } |
There was a problem hiding this comment.
No footer on the REPL of course -- I had just copy/pasted this CSS, it's not relevant anymore.
Few things I ran into in #1148 that can be extracted a bit.