Support state
See original GitHub issueIt’d be great if users could make their designs stateful.
My thinking is that we could do this in a code-oriented way by allowing usage of React hooks like this:
const [ firstName, setFirstName ] = useState('');
const [ lastName, setLastName ] = useState('');
<TextField label="First name" value={name} onChange=(event => setFirstName(event.target.value)} />
<TextField label="Last name" value={name} onChange=(event => setLastName(event.target.value)} />
For this to work, we’d need to treat the last n number of JSX elements as an implicitly returned fragment, i.e. behind the scenes we’d turn it into a component that looks like this:
() => {
const [ firstName, setFirstName ] = useState('');
const [ lastName, setLastName ] = useState('');
return (
<React.Fragment>
<TextField label="First name" value={name} onChange=(event => setFirstName(event.target.value)} />
<TextField label="Last name" value={name} onChange=(event => setName(event.target.value)} />
</React.Fragment>
);
};
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Customer Service | Support - State Water Heaters
Phone. 1-866-667-4960. Residential Water Heater Tech Support Hours. Monday - Friday 8:00 AM - 10:00 PM EST. Saturday - Sunday 9:00 AM -...
Read more >Welcome to the OCSE State Plan Data - Child Support Portal
Office of Child Support Enforcement. Administration for Children & Families ... Welcome to the OCSE State Plan Data. You are accessing a U.S....
Read more >What is State Support | IGI Global
What is State Support? Definition of State Support: A set of protective measures provided by a state to a certain industry or sector....
Read more >State support Definition | Law Insider
State support means grant by the State of any administrative support, asset-based support, foregoing revenue benefits support, undertaking contingent ...
Read more >Pennsylvania Child Support Program
Welcome to the Pennsylvania Child Support Program. On-the-go access to child support information and services. My Cases. Register or log in to manage...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi. Since code now transpiled through babel, it’s possible to alter it, so it would be component itself. I coded some solution, that takes user code, wraps it into
React.createElement(function () {})
and addsreturn
to jsx code.is transformed to
I see interesting side-effect of this solution - you don’t need
React.Fragment
anymore.Right now solution is fastcoded as PoC, so there is few broken tests. If you interested, I can continue working on it.
I just got a very simple solution:
In my components file, I export this one line component:
so it allows me to do the following on playroom: